Feat cronjob #23
@@ -98,14 +98,22 @@ func Convert(composeFile, appVersion, appName, chartDir, chartVersion string, fo
|
|||||||
fmt.Println("No compose file given")
|
fmt.Println("No compose file given")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err := os.Stat(composeFile)
|
|
||||||
if err != nil {
|
composeFiles := strings.Split(composeFile, ",")
|
||||||
fmt.Println("No compose file found")
|
for i, c := range composeFiles {
|
||||||
os.Exit(1)
|
composeFiles[i] = strings.TrimSpace(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, composeFile := range composeFiles {
|
||||||
|
_, err := os.Stat(composeFile)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error reading file:", composeFile)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the compose file now
|
// Parse the compose file now
|
||||||
p := compose.NewParser(composeFile)
|
p := compose.NewParser(composeFiles)
|
||||||
p.Parse(appName)
|
p.Parse(appName)
|
||||||
|
|
||||||
dirname := filepath.Join(chartDir, appName)
|
dirname := filepath.Join(chartDir, appName)
|
||||||
|
@@ -26,32 +26,34 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewParser create a Parser and parse the file given in filename. If filename is empty, we try to parse the content[0] argument that should be a valid YAML content.
|
// NewParser create a Parser and parse the file given in filename. If filename is empty, we try to parse the content[0] argument that should be a valid YAML content.
|
||||||
func NewParser(filename string, content ...string) *Parser {
|
func NewParser(filename []string, content ...string) *Parser {
|
||||||
|
|
||||||
p := &Parser{}
|
p := &Parser{}
|
||||||
|
|
||||||
if len(content) > 0 { // mainly for the tests...
|
if len(content) > 0 { // mainly for the tests...
|
||||||
dir := filepath.Dir(filename)
|
dir := filepath.Dir(filename[0])
|
||||||
err := os.MkdirAll(dir, 0755)
|
err := os.MkdirAll(dir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
p.temporary = &dir
|
p.temporary = &dir
|
||||||
ioutil.WriteFile(filename, []byte(content[0]), 0644)
|
ioutil.WriteFile(filename[0], []byte(content[0]), 0644)
|
||||||
cli.DefaultFileNames = []string{filename}
|
cli.DefaultFileNames = filename
|
||||||
}
|
}
|
||||||
// if filename is not in cli Default files, add it
|
// if filename is not in cli Default files, add it
|
||||||
if len(filename) > 0 {
|
if len(filename) > 0 {
|
||||||
found := false
|
found := false
|
||||||
for _, f := range cli.DefaultFileNames {
|
for _, defaultFileName := range cli.DefaultFileNames {
|
||||||
if f == filename {
|
for _, givenFileName := range filename {
|
||||||
found = true
|
if defaultFileName == givenFileName {
|
||||||
break
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add the file at first position
|
// add the file at first position
|
||||||
if !found {
|
if !found {
|
||||||
cli.DefaultFileNames = append([]string{filename}, cli.DefaultFileNames...)
|
cli.DefaultFileNames = append(filename, cli.DefaultFileNames...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user