Feat cronjob (#23)
Make possible to declare cronTabs inside docker-compose file. ⇒ Also, add multiple compose file injection with `-c` arguments ⇒ Also, fixes “ignore depends on” for same pod ⇒ Also fixes * fix [Be able to specify compose.yml files and its override #21](https://github.com/metal3d/katenary/issues/21) * fix [Be able to ignore ports to expose in a katenary.io/ports list #16](https://github.com/metal3d/katenary/issues/16) And more fixes… (later, we will use branches in a better way, that was a hard, long fix process)
This commit is contained in:
@@ -50,6 +50,7 @@ func main() {
|
||||
}
|
||||
|
||||
// convert command, need some flags
|
||||
var composeFiles *[]string
|
||||
convertCmd := &cobra.Command{
|
||||
Use: "convert",
|
||||
Short: "Convert docker-compose to helm chart",
|
||||
@@ -61,9 +62,7 @@ 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
|
||||
// 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,17 +70,17 @@ func main() {
|
||||
if err != nil {
|
||||
writers.IndentSize = indentation
|
||||
}
|
||||
Convert(composeFile, appversion, appName, chartDir, chartVersion, force)
|
||||
Convert(*composeFiles, appversion, appName, chartDir, chartVersion, force)
|
||||
},
|
||||
}
|
||||
composeFiles = convertCmd.Flags().StringArrayP(
|
||||
"compose-file", "c", []string{ComposeFile}, "compose file to convert, can be use several times to override previous file. Order is important!")
|
||||
convertCmd.Flags().BoolP(
|
||||
"force", "f", false, "force overwrite of existing output files")
|
||||
convertCmd.Flags().StringP(
|
||||
"app-version", "a", AppVersion, "app version")
|
||||
convertCmd.Flags().StringP(
|
||||
"chart-version", "v", ChartVersion, "chart version")
|
||||
convertCmd.Flags().StringP(
|
||||
"compose-file", "c", ComposeFile, "docker compose file")
|
||||
convertCmd.Flags().StringP(
|
||||
"app-name", "n", AppName, "application name")
|
||||
convertCmd.Flags().StringP(
|
||||
|
@@ -93,19 +93,24 @@ 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
|
||||
}
|
||||
_, err := os.Stat(composeFile)
|
||||
if err != nil {
|
||||
fmt.Println("No compose file found")
|
||||
os.Exit(1)
|
||||
|
||||
composeFiles := composeFile
|
||||
ComposeFile = composeFiles[0]
|
||||
|
||||
for _, cf := range composeFiles {
|
||||
if _, err := os.Stat(cf); err != nil {
|
||||
fmt.Printf("Compose file %s not found\n", cf)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the compose file now
|
||||
p := compose.NewParser(composeFile)
|
||||
p := compose.NewParser(composeFiles)
|
||||
p.Parse(appName)
|
||||
|
||||
dirname := filepath.Join(chartDir, appName)
|
||||
|
Reference in New Issue
Block a user