-
Notifications
You must be signed in to change notification settings - Fork 771
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
Conversation
@surajnarwade, thank you for the pull request! We'll request some people to review your PR. @cdrage and @kadel, please review this. |
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() |
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.
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" { |
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.
change volume to opt.Volume
fcef34e
to
6fcd9e5
Compare
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) |
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.
Just one small note here. It would be nice if message also showed what values are possible.
6fcd9e5
to
166bc93
Compare
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") |
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.
remove capitalization of Possible
change to persistentVolumeClaim and emptyDir
166bc93
to
ffcc658
Compare
@cdrage done |
@surajnarwade Please add description to commit. |
fdbe867
to
613cd6c
Compare
issue is being tracked here #814 |
@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.
613cd6c
to
269f604
Compare
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
No description provided.