Skip to content

Commit

Permalink
Merge pull request #26 from janetkuo/convert-c-y
Browse files Browse the repository at this point in the history
Support creating Charts when --yaml set
  • Loading branch information
ngtuna authored Jul 8, 2016
2 parents 2e986b6 + dea476f commit e5a1d9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
20 changes: 13 additions & 7 deletions cli/app/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e5a1d9d

Please sign in to comment.