-
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
Add validate cluster command to clusterctl #203
Conversation
Hi @wangzhen127. Thanks for your PR. I'm waiting for a kubernetes or kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with 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. |
Note that the 1st commit is basically #202. The 2nd commit is the actual PR that will be merged to add validate cluster command. /cc @karan @jessicaochen |
/hold |
I can't review this PR with 11k files. Can you take out the vendor changes and only have the core change in this PR please? |
The benefit of including the 1st commit (vendor changes) are:
|
Since I split the commits in #202, I rebased this PR. Now there are 3 commits. You can see them in commits tab.
|
clusterctl/cmd/validate_cluster.go
Outdated
} | ||
|
||
func init() { | ||
validateClusterCmd.Flags().StringVarP(&vco.Name, "name", "n", "", "Cluster name") |
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.
Please see jessica's comment here: #119 (comment)
Please leave all flags out of the skeleton. They can be filled in as code uses them. This ensures the the flags actually do something when they appear and also ensure they are defined in a way that works and is accurate to the behavior of the code.
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.
OK. I just removed it. Will add them in follow-up PRs.
Since we decided to drop internalization in #202 for now, I updated this PR to remove those changes. I also updated the PR description. PTAL /hold cancel |
clusterctl/cmd/validate_cluster.go
Outdated
}, | ||
} | ||
|
||
func RunValidateCluster() error { |
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 should be an associated _test.go file for this file. Please add a validate_cluster_test.go file, it can have a test that calls Run and verifies that errors.NotImplementedError is returned.
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.
Done
clusterctl/cmd/validate.go
Outdated
} | ||
|
||
func init() { | ||
validateCmd.AddCommand(validateClusterCmd) |
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.
To reduce confusion, we should be consistent with who is responsible for adding a sub-command. Since the validate command adds itself to the RootCmd on line 31, then it seems like we should remove line 30 and have the ValidateClusterCmd add itself to the ValidateCmd.
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.
It is not very clear to me which style to follow. createCmd is added in root.go. deleteCmd is added in delete.go instead.
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.
By the way, is there a repo wide style guideline?
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.
As you pointed out there's inconsistency in the repo. We can fix that in a follow up PR. Let's follow the style laid out in the cobra examples [1] where a given command adds itself to its parent. So that means the create command should be added in create.go. And in this case, the validateClusterCommand would add itself to the validate command in validate_cluster.go.
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.
FYI opened up a standardization PR here: #228 (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.
@spew - thanks for standardizing
+1 for following the standardized pattern.
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.
Done
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.
lgtm (will leave the actual "/" approval up to the next reviewer)
clusterctl/cmd/validate.go
Outdated
var validateCmd = &cobra.Command{ | ||
Use: "validate", | ||
Short: "Validate an API resource created by cluster API.", | ||
Long: "Validate an API resource created by cluster 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.
This can use a little more details. Validate in what way?
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.
I would actually suggest more details on the validate cluster command instead of the validate command as I suspect validation will be cluster API resource-specific.
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.
I agree with Jessica.
And I think it is very early and there is no real implementation yet. I intend to update the help message as I add more stuff in follow-up PRs.
clusterctl/cmd/validate.go
Outdated
} | ||
|
||
func init() { | ||
validateCmd.AddCommand(validateClusterCmd) |
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.
@spew - thanks for standardizing
+1 for following the standardized pattern.
clusterctl/cmd/validate.go
Outdated
var validateCmd = &cobra.Command{ | ||
Use: "validate", | ||
Short: "Validate an API resource created by cluster API.", | ||
Long: "Validate an API resource created by cluster 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.
I would actually suggest more details on the validate cluster command instead of the validate command as I suspect validation will be cluster API resource-specific.
Updated the PR with fixes. PTAL |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: spew, wangzhen127 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:
Approvers can indicate their approval by writing |
I just noticed that testify was not in vendor/ from the failed test. So I added it in Gopkg.toml and ran dep ensure. Currently I put them as separate commits for easier review. I will squash after someone take a look. |
So to date we have been avoiding testify in this repository and have been relying on writing out if statements. The reasoning comes from the golang FAQ: https://golang.org/doc/faq#testing_framework
I think we need a decision on this and make it a repository mandate or not. Maybe we can conduct this discussion in Slack or have an issue vote. |
/ok-to-test |
OK. I updated the test to use if statement. PTAL |
/lgtm |
OCPBUGS-30480: Merge https://github.com/kubernetes-sigs/cluster-api:v1.6.4 (36c0e55) into master
What this PR does / why we need it:
This PR adds validate cluster command to clusterctl. It does not have real implementations yet. This is part of #168 and there will be follow-up PRs.
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 #
Special notes for your reviewer:
Release note:
@kubernetes/kube-deploy-reviewers