Feat cronjob #23

Merged
metal3d merged 28 commits from feat-cronjob into master 2022-06-10 14:15:18 +00:00
3 changed files with 6 additions and 7 deletions
Showing only changes of commit af05e41225 - Show all commits

View File

@@ -61,9 +61,9 @@ func main() {
"- if it's not defined, so the 0.0.1 version is used", "- if it's not defined, so the 0.0.1 version is used",
Run: func(c *cobra.Command, args []string) { Run: func(c *cobra.Command, args []string) {
force := c.Flag("force").Changed 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? // TODO: is there a way to get typed values from cobra?
appversion := c.Flag("app-version").Value.String() appversion := c.Flag("app-version").Value.String()
composeFile := c.Flag("compose-file").Value.String()
appName := c.Flag("app-name").Value.String() appName := c.Flag("app-name").Value.String()
chartVersion := c.Flag("chart-version").Value.String() chartVersion := c.Flag("chart-version").Value.String()
chartDir := c.Flag("output-dir").Value.String() chartDir := c.Flag("output-dir").Value.String()
@@ -71,7 +71,7 @@ func main() {
if err != nil { if err != nil {
writers.IndentSize = indentation writers.IndentSize = indentation
} }
Convert(composeFile, appversion, appName, chartDir, chartVersion, force) Convert(*composeFile, appversion, appName, chartDir, chartVersion, force)
}, },
} }
convertCmd.Flags().BoolP( convertCmd.Flags().BoolP(

View File

@@ -93,15 +93,14 @@ func detectGitVersion() (string, error) {
return defaulVersion, errors.New("git log failed") 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 { if len(composeFile) == 0 {
fmt.Println("No compose file given") fmt.Println("No compose file given")
return return
} }
composeFiles := strings.Split(composeFile, ",") for i, c := range composeFile {
for i, c := range composeFiles { composeFile[i] = strings.TrimSpace(c)
composeFiles[i] = strings.TrimSpace(c)
} }
for _, composeFile := range composeFiles { for _, composeFile := range composeFiles {

View File

@@ -127,7 +127,7 @@ func setUp(t *testing.T) (string, *compose.Parser) {
} }
composefile := filepath.Join(tmpwork, "docker-compose.yaml") 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 // create envfile for "useenvfile" service
err = os.Mkdir(filepath.Join(tmpwork, "config"), 0777) err = os.Mkdir(filepath.Join(tmpwork, "config"), 0777)