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

Use loadModel instead of loadModelWithLatestAPIVersion for crossplane #240

Merged
merged 4 commits into from
Nov 17, 2021

Conversation

EdgeJ
Copy link
Contributor

@EdgeJ EdgeJ commented Nov 10, 2021

getLatestAPIVersion doesn't seem to work correctly with crossplane, and
opgGenVersion is already used to find the configuration path for
resources, so just use that instead.

Issue #, if available:

Description of changes:

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

getLatestAPIVersion doesn't seem to work correctly with crossplance, and
opgGenVersion is already used to find the configuration path for
resources, so just use that instead.
@ack-bot
Copy link
Collaborator

ack-bot commented Nov 10, 2021

Hi @EdgeJ. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions 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.

@ack-bot ack-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 10, 2021
@a-hilaly
Copy link
Member

/ok-to-test

@ack-bot ack-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 10, 2021
@AaronME
Copy link
Contributor

AaronME commented Nov 10, 2021

@EdgeJ - Thanks for the quick fix. Glad you were on top of it.

I'm still getting v1beta1 resources with this commit, and resources in the "services.k8s.aws" apiGroup.

loadModel is using the default ackgenerate.DefaultConfig and not the one created for Crossplane in pkg/generate/crossplane/

See

sdkAPI, optGenVersion, cfgPath, cpgenerate.DefaultConfig,
for reference.

It looks like this was changed in 79b8dd7#diff-6c9b11a8ab6c3f28f4ad6ee4d3f7f5b1c9da81f13ac772b15c784aa95f0ded10 and we haven't caught it until now.

loadModel needs to support passing in alternative sdkHelpers and defaultConfigs, or else we will need to duplicate the flow for the crossplane resources.

@EdgeJ
Copy link
Contributor Author

EdgeJ commented Nov 10, 2021

/hold

@ack-bot ack-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 10, 2021
@EdgeJ
Copy link
Contributor Author

EdgeJ commented Nov 10, 2021

@EdgeJ - Thanks for the quick fix. Glad you were on top of it.

I'm still getting v1beta1 resources with this commit, and resources in the "services.k8s.aws" apiGroup.

loadModel is using the default ackgenerate.DefaultConfig and not the one created for Crossplane in pkg/generate/crossplane/

See

sdkAPI, optGenVersion, cfgPath, cpgenerate.DefaultConfig,

for reference.
It looks like this was changed in 79b8dd7#diff-6c9b11a8ab6c3f28f4ad6ee4d3f7f5b1c9da81f13ac772b15c784aa95f0ded10 and we haven't caught it until now.

loadModel needs to support passing in alternative sdkHelpers and defaultConfigs, or else we will need to duplicate the flow for the crossplane resources.

Thanks for the insight @AaronME , I didn't realize the commit adding the model name configuration wiped out some necessary configs for crossplane. I don't think it should be too difficult to add that back into with this PR, but as you pointed out, we may just need to duplicate some of the functionality in loadModel with crossplane specific configuration.

@RedbackThomson
Copy link
Contributor

Thanks for the insight @AaronME , I didn't realize the commit adding the model name configuration wiped out some necessary configs for crossplane. I don't think it should be too difficult to add that back into with this PR, but as you pointed out, we may just need to duplicate some of the functionality in loadModel with crossplane specific configuration.

Ugh I totally missed that detail in that PR. I will make a note to include a crossplane smoke test in our e2e test suite so that this doesn't happen again. Appreciate you taking the time to diagnose this!

@EdgeJ
Copy link
Contributor Author

EdgeJ commented Nov 10, 2021

/unhold

@ack-bot ack-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 10, 2021
@EdgeJ
Copy link
Contributor Author

EdgeJ commented Nov 10, 2021

Added some flags to the root command to be able to control what default configs to use (right now, only the ACK default and Crossplane default) and to dynamically set the API group name. I think this should take care of the issues we were seeing. At any rate, tests out well on my machine doing dry run builds of some existing resources.

@RedbackThomson
Copy link
Contributor

Added some flags to the root command to be able to control what default configs to use (right now, only the ACK default and Crossplane default) and to dynamically set the API group name. I think this should take care of the issues we were seeing. At any rate, tests out well on my machine doing dry run builds of some existing resources.

I don't expect that anyone would ever use the ACK defaults with this crossplane generator - so I am happy with just hardcoding that and removing the option. As for the API group name, is this something crossplane would likely override?

@EdgeJ
Copy link
Contributor Author

EdgeJ commented Nov 12, 2021

Added some flags to the root command to be able to control what default configs to use (right now, only the ACK default and Crossplane default) and to dynamically set the API group name. I think this should take care of the issues we were seeing. At any rate, tests out well on my machine doing dry run builds of some existing resources.

I don't expect that anyone would ever use the ACK defaults with this crossplane generator - so I am happy with just hardcoding that and removing the option. As for the API group name, is this something crossplane would likely override?

I don't think it's too likely. I'll go ahead and remove those flags and just hard code the crossplane command to set the specific configurations in loadModel instead.

@EdgeJ EdgeJ force-pushed the fix-crossplane-api-versions branch from d3a6c7b to 4605874 Compare November 12, 2021 16:45
@EdgeJ
Copy link
Contributor Author

EdgeJ commented Nov 12, 2021

/retest

Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

A few suggestions inline...

cmd/ack-generate/command/root.go Outdated Show resolved Hide resolved

if cpAPIGroupSuffix != "" {
sdkAPI.APIGroupSuffix = cpAPIGroupSuffix
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of the conditionals above, how about adding new apiGroup and defaultCfg parameters to the loadModel function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is the best approach. I think I didn't consider this before because I was trying to touch as few places as possible, but it turns out only one other package uses this function outside the ones I've already changed.

cmd/ack-generate/command/crossplane.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Nice. Much cleaner! :)

@jaypipes
Copy link
Collaborator

/lgtm

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

ack-bot commented Nov 17, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: EdgeJ, jaypipes, RedbackThomson

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 [RedbackThomson,jaypipes]

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 966e9a9 into aws-controllers-k8s:main Nov 17, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
6 participants