diff --git a/cmd/katenary/main.go b/cmd/katenary/main.go index 712f057..de1ce08 100644 --- a/cmd/katenary/main.go +++ b/cmd/katenary/main.go @@ -61,9 +61,9 @@ func main() { "- if it's not defined, so the 0.0.1 version is used", Run: func(c *cobra.Command, args []string) { force := c.Flag("force").Changed + composeFile := c.Flags().StringArrayP("compose-file", "c", []string{}, "compose file to convert, can be use several times to override previous file (default: docker-compose.yml)") // TODO: is there a way to get typed values from cobra? appversion := c.Flag("app-version").Value.String() - composeFile := c.Flag("compose-file").Value.String() appName := c.Flag("app-name").Value.String() chartVersion := c.Flag("chart-version").Value.String() chartDir := c.Flag("output-dir").Value.String() @@ -71,7 +71,7 @@ func main() { if err != nil { writers.IndentSize = indentation } - Convert(composeFile, appversion, appName, chartDir, chartVersion, force) + Convert(*composeFile, appversion, appName, chartDir, chartVersion, force) }, } convertCmd.Flags().BoolP( diff --git a/cmd/katenary/utils.go b/cmd/katenary/utils.go index 9e179e5..2f6d071 100644 --- a/cmd/katenary/utils.go +++ b/cmd/katenary/utils.go @@ -93,15 +93,14 @@ func detectGitVersion() (string, error) { return defaulVersion, errors.New("git log failed") } -func Convert(composeFile, appVersion, appName, chartDir, chartVersion string, force bool) { +func Convert(composeFile []string, appVersion, appName, chartDir, chartVersion string, force bool) { if len(composeFile) == 0 { fmt.Println("No compose file given") return } - composeFiles := strings.Split(composeFile, ",") - for i, c := range composeFiles { - composeFiles[i] = strings.TrimSpace(c) + for i, c := range composeFile { + composeFile[i] = strings.TrimSpace(c) } for _, composeFile := range composeFiles { diff --git a/generator/main_test.go b/generator/main_test.go index 7a57006..c90ca39 100644 --- a/generator/main_test.go +++ b/generator/main_test.go @@ -127,7 +127,7 @@ func setUp(t *testing.T) (string, *compose.Parser) { } composefile := filepath.Join(tmpwork, "docker-compose.yaml") - p := compose.NewParser(composefile, DOCKER_COMPOSE_YML) + p := compose.NewParser([]string{composefile}, DOCKER_COMPOSE_YML) // create envfile for "useenvfile" service err = os.Mkdir(filepath.Join(tmpwork, "config"), 0777)