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

Fixed --volumes validation #817

Merged
merged 1 commit into from
Sep 26, 2017
Merged

Conversation

surajnarwade
Copy link
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 14, 2017
@kompose-bot
Copy link
Collaborator

@surajnarwade, thank you for the pull request! We'll request some people to review your PR. @cdrage and @kadel, please review this.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 14, 2017
pkg/app/app.go Outdated
@@ -76,6 +76,9 @@ func ValidateFlags(bundle string, args []string, cmd *cobra.Command, opt *kobjec
replicationController := cmd.Flags().Lookup("replication-controller").Changed
deployment := cmd.Flags().Lookup("deployment").Changed

//Check volume flag
volume := cmd.Flags().Lookup("volumes").Value.String()
Copy link
Member

Choose a reason for hiding this comment

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

No need to do a look up. It's available at opt.Volume

pkg/app/app.go Outdated
@@ -133,6 +136,10 @@ func ValidateFlags(bundle string, args []string, cmd *cobra.Command, opt *kobjec
if opt.GenerateJSON && opt.GenerateYaml {
log.Fatalf("YAML and JSON format cannot be provided at the same time")
}

if volume != "persistentVolumeClaim" && volume != "emptyDir" {
Copy link
Member

Choose a reason for hiding this comment

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

change volume to opt.Volume

@surajnarwade
Copy link
Contributor Author

@cdrage , @kadel needs your review here :)

@kadel
Copy link
Member

kadel commented Sep 18, 2017

ref #814

pkg/app/app.go Outdated
@@ -133,6 +133,10 @@ func ValidateFlags(bundle string, args []string, cmd *cobra.Command, opt *kobjec
if opt.GenerateJSON && opt.GenerateYaml {
log.Fatalf("YAML and JSON format cannot be provided at the same time")
}

if opt.Volumes != "persistentVolumeClaim" && opt.Volumes != "emptyDir" {
log.Fatal("Unknown Volume type: ", opt.Volumes)
Copy link
Member

Choose a reason for hiding this comment

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

Just one small note here. It would be nice if message also showed what values are possible.

pkg/app/app.go Outdated
@@ -133,6 +133,10 @@ func ValidateFlags(bundle string, args []string, cmd *cobra.Command, opt *kobjec
if opt.GenerateJSON && opt.GenerateYaml {
log.Fatalf("YAML and JSON format cannot be provided at the same time")
}

if opt.Volumes != "persistentVolumeClaim" && opt.Volumes != "emptyDir" {
log.Fatal("Unknown Volume type: ", opt.Volumes, ", Possible values are: persistentVolumeClaim, emptyDir")
Copy link
Member

Choose a reason for hiding this comment

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

remove capitalization of Possible

change to persistentVolumeClaim and emptyDir

@surajnarwade
Copy link
Contributor Author

@cdrage done

@cdrage
Copy link
Member

cdrage commented Sep 18, 2017

@surajnarwade Please add description to commit.

@surajnarwade surajnarwade force-pushed the vol_validation branch 2 times, most recently from fdbe867 to 613cd6c Compare September 20, 2017 13:12
@surajnarwade
Copy link
Contributor Author

issue is being tracked here #814

@cdrage
Copy link
Member

cdrage commented Sep 20, 2017

@surajnarwade can you add a test? unit / cli test (make sure it fails if someone puts --volumes=foobar or something)

Now, `--volumes` argument will validate it's input, it will only allow
`persistentVolumeClaim` or `emptyDir`, otherwise it will throw an error.
Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

lgtm

@cdrage cdrage merged commit d3df8d2 into kubernetes:master Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants