-
Notifications
You must be signed in to change notification settings - Fork 235
Allow manual setting of AWS client struct and interface names #422
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
Conversation
|
/test lambda-controller-test |
|
Pipes are always a problem. |
jaypipes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@a-hilaly @embano1 I think it would be better to just rely on the aws-sdk-go/private/model/api.API InterfaceName and StructName methods.
@jaypipes Unfortunately, those don't work properly for us. The reason is that the |
@a-hilaly can you prove this? I don't understand why those two methods won't work for this use case... |
|
@jaypipes |
| if a == nil || a.API == nil { | ||
| return "" | ||
| } | ||
| return fmt.Sprintf("%s%s", a.API.StructName(), "API") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a.API.InterfaceName() by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no a.API.InterfaceName :/ . However there a a.API.InterfacePackageName but it return the package name that defines the interface.. which is not what we need here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we used to do something similar within the Go templates: https://github.com/aws-controllers-k8s/code-generator/pull/422/files#diff-427fe62c26e82668e3c6509c81e7230831d3e652b8e836cc7a54be8a52c84405L68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looking in the upstream code they indeed use StructName ... :/
While developing the ACK pipes-controller, we encountered an issue where the generated code didn't compile mainly because the code-generator assumed that the AWS SDK client/interface/import-paths always followed the same naming convetions. However, we discovered that pipes was the exception as they renamed the model, import path and client struct/interface. This patch introduces a new feature that enables users to manually set the client structg and interface names int he `generator.yaml` file. This update allows for greater flexibvility in the AWS client naming within pipes-controller and possibly other controllers in the future. In this patch, we've also introduced a breaking change by renaming `model_name` to `sdk_names.model`. Mianly to keep all the SDK related naming convetions in the same place. Signed-off-by: Amine Hilaly <[email protected]>
|
@a-hilaly: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
RedbackThomson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to approve this. I'm a bit tentative about the naming, only because I don't fully understand the difference between these. Would you mind adding examples for each of these to the PR description for our reference? (examples of the normal default, and then what pipes does differently?)
jaypipes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| if a == nil || a.API == nil { | ||
| return "" | ||
| } | ||
| return fmt.Sprintf("%s%s", a.API.StructName(), "API") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looking in the upstream code they indeed use StructName ... :/
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly, jaypipes, RedbackThomson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@jaypipes After this commit I'm seeing errors when running ack-generate crossplane for the prometheusservice in the crossplane-contrib/provider-aws project: The Makefile is generating a list of services from the directories in https://github.com/crossplane-contrib/provider-aws/tree/master/apis that contain generator_config.yaml files. This logic worked until these changes were applied. I can dig into it more tomorrow but I thought I would check to see if it's something obvious that we can change on the provider-aws side. Thanks |
|
@bobh66 you need to switch model_name to sdk_names.model |
|
Thanks @haarchri - that fixed it. For future reference if this comes up as a search result, the specific change is: model_name: footo sdk_names:
model_name: foo |
|
modified PR description to include the example you provided @bobh66 . Thank you folks! |
While developing the ACK pipes-controller, we encountered an issue where
the generated code didn't compile mainly because the code-generator
assumed that the AWS SDK client/interface/import-paths always followed
the same naming conventions. However, we discovered that Pipes was the
exception as they renamed the model, import path, and client
struct/interface.
This patch introduces a new feature that enables users to manually set
the client struct and interface names in the
generator.yamlfile.This update allows for greater flexibility in the AWS client naming
within pipes-controller and possibly other controllers in the future.
In this patch, we've also introduced a breaking change by renaming
model_nametosdk_names.model. Mainly to keep all the SDK-relatednaming conventions in the same place.
e.g:
old configuration:
new configuration:
Signed-off-by: Amine Hilaly [email protected]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.