Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow separate service ID and alias #211

Merged
merged 3 commits into from
Sep 30, 2021

Conversation

RedbackThomson
Copy link
Contributor

Fixes aws-controllers-k8s/community#994

Description of changes:
This pull request supports including an optional --model-name command line argument for any ack-generate generator verb. The generator will use this argument to override the service name when looking up the API files in aws-sdk-go/models/apis.

Currently we reference the metadata.serviceId field from the api-2.json file as the ServiceIDClean variable. ServiceIDClean is used in all code generator templates as the import path for aws-sdk-go and when referencing the controller name (eg. {{ .ServiceIDClean}}-controller). This pull request will redirect ServiceIDClean to use the service alias provided when calling ack-generate, instead. Therefore, all subsequent ACK repositories should be named according to the AWS SDK Go package name, rather than the API file's definition of serviceId.

ServiceID has been removed from the template variables, instead replaced by AWSSDKModelServiceID if it is needed. ServiceIDClean now refers to the name of the AWS SDK Go package name.

For services that need to use the --model-name command line argument, such as opensearchservice and elbv2, developers should use the ACK_GENERATE_MODEL_NAME environment variable when calling make build-controller. Changes to the CI/CD system will need to be made to accommodate this customisation.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@RedbackThomson
Copy link
Contributor Author

Note to the reviewers: I'm happy to discuss changing the template variable ServiceIDClean to ServiceAliasClean - to reduce confusion about re-using the term ServiceID without it referring to metadata.serviceId. I didn't make that change yet because it's used in a LOT of places in the code-generator.

@RedbackThomson RedbackThomson changed the title Split service Allow separate service ID and alias Sep 28, 2021
Copy link
Contributor

@vijtrip2 vijtrip2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
pkg/testutil/schema_helper.go needs some changes as well

@a-hilaly
Copy link
Member

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Sep 30, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, RedbackThomson, vijtrip2

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson,vijtrip2]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit 15c7f5c into aws-controllers-k8s:main Sep 30, 2021
@@ -34,6 +31,9 @@ type MetaVars struct {
// for custom resources, e.g. "sns.services.k8s.aws" or
// "sfn.services.k8s.aws"
APIGroup string
// AWSSDKModelServiceID is the exact string that appears in the AWS service API's
// api-2.json descriptor file under `metadata.serviceId`
AWSSDKModelServiceID string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably could have just been SDKModelServiceID to match the SDKAPIInterfaceTypeName field below.

@RedbackThomson RedbackThomson deleted the split-service branch October 4, 2021 20:56
RedbackThomson pushed a commit to RedbackThomson/ack-code-generator that referenced this pull request Oct 7, 2021
ack-bot pushed a commit that referenced this pull request Oct 7, 2021
Description of changes:
Reverts #214 and #211 in favour of using the `generator.yaml` file to store the service model name

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
acornett21 pushed a commit to acornett21/ack-code-generator that referenced this pull request Oct 12, 2021
Description of changes:
Reverts aws-controllers-k8s#214 and aws-controllers-k8s#211 in favour of using the `generator.yaml` file to store the service model name

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
ack-bot pushed a commit that referenced this pull request Oct 13, 2021
Issue #, if available: aws-controllers-k8s/community#994

Description of changes:
This pull request replaces all templates and variables with a defined nomenclature. The current code-generator uses service name terms interchangeably, which eventually lead to the linked issue. While PR #211 solved the logical issue of overriding the service model name, in some cases, it did not do a clear job of clarifying what names exist for any service and when they are applicable.

There are 3 different names that are used to programmatically reference a service. Here are the terms I am using in this PR to refer to them, and their given purpose:
- Service ID
  - The `metadata.serviceID` field from the model `api-2.json` file
- Service model name
  - The path to the model `api-2.json` file
- Service package name
  - The AWS SDK Go package path
  - Used by the ACK controller's for their name 

Some examples on when these differ:
- Step Functions uses `sfn` for its ID and alias, but `states` for its model name
- Elastic Load Balancing v2 uses `elbv2` for its alias, but `elasticloadbalancingv2` for its ID and model name

There are also 2 names defined in the controller metadata file that are not used in any parts of the code, but are used in documentation:
- Service name
  - The full name of the service as defined by the product's documentation page (eg. `Amazon Elastic Cloud Compute`)
-  Service short name
  - An informal, shortened name of the service (eg. `EC2`)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-sdk-go package name doesn't match service ID
5 participants