diff --git a/cli/app/app.go b/cli/app/app.go index bb1481f0..084be7a6 100644 --- a/cli/app/app.go +++ b/cli/app/app.go @@ -816,7 +816,7 @@ func ProjectKuberConvert(p *project.Project, c *cli.Context) { /* Need to iterate through one more time to ensure we capture all service/rc */ for name := range p.Configs { if c.BoolT("chart") { - err := generateHelm(composeFile, name) + err := generateHelm(composeFile, name, generateYaml) if err != nil { logrus.Fatalf("Failed to create Chart data: %s\n", err) } diff --git a/cli/app/k8sutils.go b/cli/app/k8sutils.go index 8e33f55f..2a54867d 100644 --- a/cli/app/k8sutils.go +++ b/cli/app/k8sutils.go @@ -31,7 +31,7 @@ import ( /** * Generate Helm Chart configuration */ -func generateHelm(filename string, svcname string) error { +func generateHelm(filename string, svcname string, generateYaml bool) error { type ChartDetails struct { Name string } @@ -87,22 +87,28 @@ home: } } - /* Copy all yaml files into the newly created manifests directory */ - infile, err := ioutil.ReadFile(svcname + "-rc.json") + /* Copy all related json/yaml files into the newly created manifests directory */ + // TODO: support copying controller files other than rc? + // TODO: support copying the file specified by --out? + extension := ".json" + if generateYaml { + extension = ".yaml" + } + infile, err := ioutil.ReadFile(svcname + "-rc" + extension) if err != nil { - logrus.Infof("Error reading %s: %s\n", svcname+"-rc.yaml", err) + logrus.Infof("Error reading %s: %s\n", svcname+"-rc"+extension, err) return err } - err = ioutil.WriteFile(manifestDir+string(os.PathSeparator)+svcname+"-rc.json", infile, 0644) + err = ioutil.WriteFile(manifestDir+string(os.PathSeparator)+svcname+"-rc"+extension, infile, 0644) if err != nil { return err } /* The svc file is optional */ - infile, err = ioutil.ReadFile(svcname + "-svc.json") + infile, err = ioutil.ReadFile(svcname + "-svc" + extension) if err == nil { - err = ioutil.WriteFile(manifestDir+string(os.PathSeparator)+svcname+"-svc.json", infile, 0644) + err = ioutil.WriteFile(manifestDir+string(os.PathSeparator)+svcname+"-svc"+extension, infile, 0644) if err != nil { return err }