forked from LaconicNetwork/kompose
Merge pull request #26 from janetkuo/convert-c-y
Support creating Charts when --yaml set
This commit is contained in:
commit
e5a1d9dd9c
@ -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 */
|
/* Need to iterate through one more time to ensure we capture all service/rc */
|
||||||
for name := range p.Configs {
|
for name := range p.Configs {
|
||||||
if c.BoolT("chart") {
|
if c.BoolT("chart") {
|
||||||
err := generateHelm(composeFile, name)
|
err := generateHelm(composeFile, name, generateYaml)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Failed to create Chart data: %s\n", err)
|
logrus.Fatalf("Failed to create Chart data: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import (
|
|||||||
/**
|
/**
|
||||||
* Generate Helm Chart configuration
|
* Generate Helm Chart configuration
|
||||||
*/
|
*/
|
||||||
func generateHelm(filename string, svcname string) error {
|
func generateHelm(filename string, svcname string, generateYaml bool) error {
|
||||||
type ChartDetails struct {
|
type ChartDetails struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
@ -87,22 +87,28 @@ home:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy all yaml files into the newly created manifests directory */
|
/* Copy all related json/yaml files into the newly created manifests directory */
|
||||||
infile, err := ioutil.ReadFile(svcname + "-rc.json")
|
// 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 {
|
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
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The svc file is optional */
|
/* The svc file is optional */
|
||||||
infile, err = ioutil.ReadFile(svcname + "-svc.json")
|
infile, err = ioutil.ReadFile(svcname + "-svc" + extension)
|
||||||
if err == nil {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user