-
Notifications
You must be signed in to change notification settings - Fork 770
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
make YAML the default kompose conversion #339
Conversation
Still waiting for #304 to be merged too :( |
@procrypt no idea, depending on the reviews, if you can review it too + test it, that'll speed up the process :) |
@cdrage I'm on it 😃 |
@procrypt so we don't remove a flag, we will add another flag for json output, default output to yaml and also there is a way in cmdline framework to mention what flag is gonna be deprecated. Remove flag of yaml right away might break things. |
1b2f821
to
711d914
Compare
@@ -163,6 +164,7 @@ func validateControllers(opt *kobject.ConvertOptions) { | |||
} | |||
|
|||
// Convert transforms docker compose or dab file to k8s objects | |||
|
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.
excess space between function and its definition
711d914
to
fa36f31
Compare
@surajssd @containscafeine @cdrage @pradeepto I have updated the PR. Please review. $ kompose convert
INFO[0000] file "mlbparks-service.yaml" created
INFO[0000] file "mongodb-service.yaml" created
INFO[0000] file "mlbparks-deployment.yaml" created
INFO[0000] file "mongodb-deployment.yaml" created
INFO[0000] file "mongodb-claim0-persistentvolumeclaim.yaml" created $kompose convert -j
Flag --json has been deprecated, use --yaml or -y
INFO[0000] file "mlbparks-service.json" created
INFO[0000] file "mongodb-service.json" created
INFO[0000] file "mlbparks-deployment.json" created
INFO[0000] file "mongodb-deployment.json" created
INFO[0000] file "mongodb-claim0-persistentvolumeclaim.json" created |
@@ -87,6 +88,9 @@ func init() { | |||
|
|||
// Standard between the two | |||
convertCmd.Flags().BoolVarP(&ConvertYaml, "yaml", "y", false, "Generate resource files into yaml format") | |||
convertCmd.Flags().BoolVarP(&ConvertJson, "json", "j", false, "Generate resource files into yaml format") | |||
convertCmd.Flags().MarkDeprecated("json", "use --yaml or -y") |
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.
We are deprecating -y
right?
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.
Right and thanks for the catch, I depreciated the wrong flag.
@procrypt for making tests work you will have to add |
@surajssd Since we want the default conversion to be in |
8d2c92b
to
b102e1a
Compare
9b7ea58
to
fe800ab
Compare
@@ -46,6 +46,7 @@ var convertCmd = &cobra.Command{ | |||
ToStdout: ConvertStdout, | |||
CreateChart: ConvertChart, | |||
GenerateYaml: ConvertYaml, | |||
GenerateJson: ConvertJson, |
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 think we can get rid of ConvertYaml
in code everywhere, since we are not checking on it anymore.
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.
After doing some iterations on trying to get rid of ConvertYaml it feels like it's only making code more convoluted in terms of making checks and validation, I think we can get rid of ConvertYaml once we decide we wanna get rid of the flag.
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.
@surajssd feels cleaner to have both, right? json + yaml generation (by default, you can set the value of GenerateYaml to true
in cobra)
ConvertOpt kobject.ConvertOptions | ||
ConvertSource, ConvertOut, ConvertBuildRepo, ConvertBuildBranch string | ||
ConvertChart, ConvertDeployment, ConvertDaemonSet bool | ||
ConvertReplicationController, ConvertYaml, ConvertStdout, ConvertJson bool |
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.
@@ -37,6 +37,7 @@ type ConvertOptions struct { | |||
BuildBranch string | |||
CreateChart bool | |||
GenerateYaml bool |
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.
@@ -93,6 +94,9 @@ func init() { | |||
|
|||
// Standard between the two | |||
convertCmd.Flags().BoolVarP(&ConvertYaml, "yaml", "y", false, "Generate resource files into yaml format") |
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.
once convertyaml is removed this should still be functional for sometime, so if this flag is set what can be done here is set ConvertJson to be false.
Just to be sure check if user is not giving -y and -j simultaneously. |
@surajssd Added the check for not providing -y and -j simultaneously. |
d8ae85a
to
6c5174b
Compare
@procrypt code LGTM, one last bit of update docs: https://github.com/kubernetes-incubator/kompose/blob/master/docs/user-guide.md and https://github.com/kubernetes-incubator/kompose#use-case |
@procrypt Tests need to be converted to check against yaml instead. |
@@ -46,6 +46,7 @@ var convertCmd = &cobra.Command{ | |||
ToStdout: ConvertStdout, | |||
CreateChart: ConvertChart, | |||
GenerateYaml: ConvertYaml, | |||
GenerateJson: ConvertJson, |
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.
@surajssd feels cleaner to have both, right? json + yaml generation (by default, you can set the value of GenerateYaml to true
in cobra)
@@ -93,6 +94,9 @@ func init() { | |||
|
|||
// Standard between the two | |||
convertCmd.Flags().BoolVarP(&ConvertYaml, "yaml", "y", false, "Generate resource files into yaml format") | |||
convertCmd.Flags().MarkDeprecated("yaml", "YAML is the default format now.") | |||
convertCmd.Flags().MarkShorthandDeprecated("y", "YAML is the default format now.") | |||
convertCmd.Flags().BoolVarP(&ConvertJson, "json", "j", false, "Generate resource files into json format") |
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.
JSON should be capitalized
@@ -124,6 +124,10 @@ func ValidateFlags(bundle string, args []string, cmd *cobra.Command, opt *kobjec | |||
if len(args) != 0 { | |||
logrus.Fatal("Unknown Argument(s): ", strings.Join(args, ",")) | |||
} | |||
|
|||
if opt.GenerateJson && opt.GenerateYaml { | |||
logrus.Fatalf("Error: 'YAML' and 'JSON' format cannot be provided at the same time") |
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 add Error:
. and IMO YAML and JSON shouldn't be in quotes.
@procrypt thanks for awesome work 👍 🎉 |
thanks @procrypt 👍 |
FIX #306
cc @kadel @surajssd