-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ Introduce version check validation for generate provider command #5933
✨ Introduce version check validation for generate provider command #5933
Conversation
Welcome @tharun208! |
Hi @tharun208. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fc9c58f
to
ec48ded
Compare
Signed-off-by: tharun <[email protected]>
ec48ded
to
e6cfe94
Compare
/ok-to-test |
@tharun208: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
@tharun208 Thank you for getting the PR out. 🙂 |
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.
First pass review:
It mostly looks good, expect for the default version case.
// namespace etc. | ||
// Currently we are not supporting custom yaml processors for the provider | ||
// components. So we revert to using the default SimpleYamlProcessor. | ||
repositoryClientFactory, err := c.repositoryClientFactory(RepositoryClientFactoryInput{Provider: providerConfig}) |
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.
repositoryClientFactory, err := c.repositoryClientFactory(RepositoryClientFactoryInput{Provider: providerConfig}) | |
repositoryClient, err := c.repositoryClientFactory(RepositoryClientFactoryInput{Provider: providerConfig}) |
nit: the factory returns a client not another factory.
// Currently we are not supporting custom yaml processors for the provider | ||
// components. So we revert to using the default SimpleYamlProcessor. |
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.
// Currently we are not supporting custom yaml processors for the provider | |
// components. So we revert to using the default SimpleYamlProcessor. |
IMHO, I dont think you need these comments here. Also, If the defaulting changes these comments will become false.
|
||
providerName, providerVersion, err := parseProviderName(providerName) | ||
if err != nil { | ||
return nil, err |
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.
return nil, err | |
return nil, errrors.Wrap(err, "failed to parse provider name") |
Wrapping the errors provides more context when something fails.
If you can also wrap other errors below that would be great.
} | ||
releaseSeries := latestMetadata.GetReleaseSeriesForVersion(currentVersion) | ||
if releaseSeries.Contract != clusterv1.GroupVersion.Version { | ||
return nil, errors.Errorf("current version of clusterctl is only compatible with %s providers, detected %s for provider %s", clusterv1.GroupVersion.Version, releaseSeries.Contract, providerVersion) |
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.
return nil, errors.Errorf("current version of clusterctl is only compatible with %s providers, detected %s for provider %s", clusterv1.GroupVersion.Version, releaseSeries.Contract, providerVersion) | |
return nil, errors.Errorf("current version of clusterctl is only compatible with %s providers, detected %s for provider version %s", clusterv1.GroupVersion.Version, releaseSeries.Contract, providerVersion) |
return nil, err | ||
} | ||
|
||
latestMetadata, err := repositoryClientFactory.Metadata(providerVersion).Get() |
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.
This command is also supposed to work when a user does not provider a version in the input (Example: clusterctl generate provider -i aws
). In such cases the providerVersion
here will be empty and this command will fail. If the user does not provider a version we have to fall back to the default version.
However, I see that the repository client here does not have a DefaultVersion
function. I would suggest adding a DefaultVersion
function to the repository.Client interface and to the implementation (type repositoryClient struct {...}
).
You can have something like this:
func (c *repositoryClient) DefaultVersion() string {
return c.repository.DefaultVersion()
}
@fabriziopandini Thoughts about adding the DefaultVersion
function to repository.Client
interface? This interface already has a GetVersions
function. I dont think it is unreasonable to add a DefaultVersion
function.
Then, once you have access to the DefaultVersion function, after l.63 you can have to check to see if providerVersion
is empty and set it to default version. This should fix the broken use case.
@tharun208 Will you have bandwidth to continue this? |
@ykakarap will address the feedbacks this week |
@tharun208 will you have bandwidth to follow up on this? |
Any updates on this PR? |
@ykakarap can you follow up on this pr? |
I am not sure I understand. If you are asking about the next steps to do then the review on the PR still valid. Adding those changes should be a good place to start. |
@tharun208 Do you have time to address the findings? |
Going to close this for now due to inactivity, please feel free to reopen |
@vincepri: Closed this PR. In response to this:
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. |
Signed-off-by: tharun [email protected]
This PR introduces validation for incompatible versions while generating providers using the
generate provider
command.What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #5864