Skip to content
Snippets Groups Projects
Commit 47583b2d authored by Florent Aide's avatar Florent Aide
Browse files

runner: continue cmds args creation

parent cef0d887
No related branches found
No related tags found
No related merge requests found
......@@ -131,6 +131,6 @@
var args []string
switch c.Type {
case HelmType:
// helm template -f base.yaml -f base.values.yaml -f ns.yaml -f ns.values.yaml
// helm template name vendor/helm/mychart/ --namespace ns1 -f base.values.yaml -f ns.yaml -f ns.values.yaml
args = append(args, "template", name, c.Path, "--namespace", namespace)
case YttType:
......@@ -135,7 +135,5 @@
args = append(args, "template", name, c.Path, "--namespace", namespace)
case YttType:
// ytt -f $chartsTmpFile --file-mark "$(basename $chartsTmpFile):type=yaml-plain"\
// -f base/ytt/ -f base/ytt.yml -f ns1/ytt/ -f ns1/ytt.yml
args = append(args, "-f", c.Path)
default:
return nil, fmt.Errorf("unsupported chart %s type: %q", c.Path, c.Type)
......@@ -146,6 +144,9 @@
return args, nil
}
// ytt -f $chartsTmpFile --file-mark "$(basename $chartsTmpFile):type=yaml-plain"\
// -f base/ytt/ -f base/ytt.yml -f ns1/ytt/ -f ns1/ytt.yml
func cmdChartFromChart(c Chart) CmdChart {
return CmdChart{
Type: c.Type,
......
......@@ -21,10 +21,10 @@
// Build is in charge of applying commands based on the config data
func (r *Runner) Build() error {
// create helm commands
var helmCmds []*cmd.Cmd
for _, chart := range r.config.Spec.Charts {
name := "FIND_WERE_THE_NAME_COMES_FROM"
// create ytt chart commands
var cmds []*cmd.Cmd
for name, chart := range r.config.Spec.Charts {
args, err := chart.BuildArgs(name, r.config.Namespace)
if err != nil {
return fmt.Errorf("build: failed to build args %w", err)
}
......@@ -27,7 +27,14 @@
args, err := chart.BuildArgs(name, r.config.Namespace)
if err != nil {
return fmt.Errorf("build: failed to build args %w", err)
}
helmCmds = append(helmCmds, cmd.NewCmd("helm", args...))
switch chart.Type {
case HelmType:
cmds = append(cmds, cmd.NewCmd("/path/to/helm", args...))
case YttType:
cmds = append(cmds, cmd.NewCmd("/path/to/ytt", args...))
default:
return fmt.Errorf("unsupported chart %s type: %q", chart.Path, chart.Type)
}
}
......@@ -32,8 +39,6 @@
}
// create ytt chart commands
// create ytt additional command
// run commands or print them
if r.config.DryRun {
......@@ -36,11 +41,11 @@
// create ytt additional command
// run commands or print them
if r.config.DryRun {
for _, helmCmd := range helmCmds {
for _, helmCmd := range cmds {
r.config.Logger.Info().
Str("command", helmCmd.Name).
Str("args", strings.Join(helmCmd.Args, " ")).
Msg("would run command")
}
} else {
......@@ -41,10 +46,10 @@
r.config.Logger.Info().
Str("command", helmCmd.Name).
Str("args", strings.Join(helmCmd.Args, " ")).
Msg("would run command")
}
} else {
for _, helmCmd := range helmCmds {
for _, helmCmd := range cmds {
err, sdtOut, stdErr := RunCMD(helmCmd)
if err != nil {
r.config.Logger.Err(err).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment