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

make YAML the default kompose conversion #339

Merged
merged 1 commit into from
Jan 4, 2017

Conversation

procrypt
Copy link
Contributor

@procrypt procrypt commented Dec 16, 2016

FIX #306

cc @kadel @surajssd

$ 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
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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 16, 2016
@cdrage
Copy link
Member

cdrage commented Dec 16, 2016

Still waiting for #304 to be merged too :(

@procrypt
Copy link
Contributor Author

@cdrage How long do we have to wait for #304 to get merged. I have to update this PR once #304 gets merged :)

@cdrage
Copy link
Member

cdrage commented Dec 19, 2016

@procrypt no idea, depending on the reviews, if you can review it too + test it, that'll speed up the process :)

@procrypt
Copy link
Contributor Author

@cdrage I'm on it 😃

@surajssd
Copy link
Member

@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.

@procrypt procrypt force-pushed the default_yaml branch 2 times, most recently from 1b2f821 to 711d914 Compare December 27, 2016 09:39
@@ -163,6 +164,7 @@ func validateControllers(opt *kobject.ConvertOptions) {
}

// Convert transforms docker compose or dab file to k8s objects

Copy link
Member

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

@procrypt
Copy link
Contributor Author

procrypt commented Dec 28, 2016

@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

@coveralls
Copy link

Coverage Status

Coverage remained the same at 45.682% when pulling fa36f31 on procrypt:default_yaml into c80735c on kubernetes-incubator:master.

@@ -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")
Copy link
Member

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?

Copy link
Contributor Author

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.

@surajssd
Copy link
Member

@procrypt for making tests work you will have to add -j flag in all the cmd tests. Right now it creates default json so there was no flag, with your changes you will have to add that to all the tests.

@procrypt
Copy link
Contributor Author

@surajssd Since we want the default conversion to be in yaml and the output of all the tests is in json format. I was thinking to replace all the test output from json to yaml, instead of adding the -j flag.
WDYT ?

@procrypt procrypt force-pushed the default_yaml branch 2 times, most recently from 8d2c92b to b102e1a Compare December 29, 2016 10:24
@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling b102e1a on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@procrypt procrypt force-pushed the default_yaml branch 2 times, most recently from 9b7ea58 to fe800ab Compare December 29, 2016 10:41
@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling fe800ab on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling fe800ab on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@@ -46,6 +46,7 @@ var convertCmd = &cobra.Command{
ToStdout: ConvertStdout,
CreateChart: ConvertChart,
GenerateYaml: ConvertYaml,
GenerateJson: ConvertJson,
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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")
Copy link
Member

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.

@surajssd
Copy link
Member

surajssd commented Jan 2, 2017

Just to be sure check if user is not giving -y and -j simultaneously.

@procrypt
Copy link
Contributor Author

procrypt commented Jan 2, 2017

@surajssd Added the check for not providing -y and -j simultaneously.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling 88c87a3 on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling dddc533 on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling 92bb3b8 on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling 92bb3b8 on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@procrypt procrypt force-pushed the default_yaml branch 2 times, most recently from d8ae85a to 6c5174b Compare January 3, 2017 07:35
@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling d8ae85a on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling 6c5174b on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling eb08a34 on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling a1af9dc on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling 6995a69 on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.582% when pulling f49b93d on procrypt:default_yaml into 9c3fdaa on kubernetes-incubator:master.

@surajssd
Copy link
Member

surajssd commented Jan 3, 2017

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.617% when pulling 4ab3303 on procrypt:default_yaml into b059c44 on kubernetes-incubator:master.

@cdrage
Copy link
Member

cdrage commented Jan 3, 2017

@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,
Copy link
Member

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")
Copy link
Member

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")
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 add Error:. and IMO YAML and JSON shouldn't be in quotes.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.617% when pulling d17edbb on procrypt:default_yaml into b059c44 on kubernetes-incubator:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 46.617% when pulling cfcbfa8 on procrypt:default_yaml into b059c44 on kubernetes-incubator:master.

@surajssd surajssd added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 4, 2017
@surajssd
Copy link
Member

surajssd commented Jan 4, 2017

@procrypt thanks for awesome work 👍 🎉

@surajssd surajssd merged commit a14d5c2 into kubernetes:master Jan 4, 2017
@cdrage
Copy link
Member

cdrage commented Jan 4, 2017

thanks @procrypt 👍

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. lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants