mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 23:24:55 +02:00
adding args to be added in helmfile along with context to be set in helmspec (#171)
Ref #114 Changelog: * adding args to be added in helmfile along with context to be set in helmspec * making command args take precedence
This commit is contained in:
@@ -70,9 +70,9 @@ func main() {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||
args := c.String("args")
|
||||
args := getArgs(c, state)
|
||||
if len(args) > 0 {
|
||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
||||
helm.SetExtraArgs(args...)
|
||||
}
|
||||
|
||||
return state.SyncRepos(helm)
|
||||
@@ -100,9 +100,9 @@ func main() {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||
args := c.String("args")
|
||||
args := getArgs(c, state)
|
||||
if len(args) > 0 {
|
||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
||||
helm.SetExtraArgs(args...)
|
||||
}
|
||||
|
||||
values := c.StringSlice("values")
|
||||
@@ -137,9 +137,9 @@ func main() {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||
args := c.String("args")
|
||||
args := getArgs(c, state)
|
||||
if len(args) > 0 {
|
||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
||||
helm.SetExtraArgs(args...)
|
||||
}
|
||||
|
||||
if c.Bool("sync-repos") {
|
||||
@@ -217,9 +217,9 @@ func main() {
|
||||
return errs
|
||||
}
|
||||
|
||||
args := c.String("args")
|
||||
args := getArgs(c, state)
|
||||
if len(args) > 0 {
|
||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
||||
helm.SetExtraArgs(args...)
|
||||
}
|
||||
|
||||
values := c.StringSlice("values")
|
||||
@@ -248,9 +248,9 @@ func main() {
|
||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||
workers := c.Int("concurrency")
|
||||
|
||||
args := c.String("args")
|
||||
args := getArgs(c, state)
|
||||
if len(args) > 0 {
|
||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
||||
helm.SetExtraArgs(args...)
|
||||
}
|
||||
|
||||
return state.ReleaseStatuses(helm, workers)
|
||||
@@ -298,9 +298,9 @@ func main() {
|
||||
cleanup := c.Bool("cleanup")
|
||||
timeout := c.Int("timeout")
|
||||
|
||||
args := c.String("args")
|
||||
args := getArgs(c, state)
|
||||
if len(args) > 0 {
|
||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
||||
helm.SetExtraArgs(args...)
|
||||
}
|
||||
|
||||
return state.TestReleases(helm, cleanup, timeout)
|
||||
@@ -408,6 +408,7 @@ func loadDesiredStateFromFile(c *cli.Context, file string) (*state.HelmState, he
|
||||
log.Printf("err: Cannot use option --kube-context and set attribute context.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
kubeContext = st.Context
|
||||
}
|
||||
if namespace != "" {
|
||||
@@ -417,6 +418,7 @@ func loadDesiredStateFromFile(c *cli.Context, file string) (*state.HelmState, he
|
||||
}
|
||||
st.Namespace = namespace
|
||||
}
|
||||
|
||||
if len(labels) > 0 {
|
||||
err = st.FilterReleases(labels)
|
||||
if err != nil {
|
||||
@@ -459,3 +461,12 @@ func clean(state *state.HelmState, errs []error) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getArgs(c *cli.Context, state *state.HelmState) []string {
|
||||
args := c.String("args")
|
||||
if len(args) > 0 {
|
||||
state.HelmDefaults.Args = strings.Split(args, " ")
|
||||
}
|
||||
|
||||
return state.HelmDefaults.Args
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
// HelmState structure for the helmfile
|
||||
type HelmState struct {
|
||||
BaseChartPath string
|
||||
HelmDefaults HelmSpec `yaml:"helmDefaults"`
|
||||
Context string `yaml:"context"`
|
||||
DeprecatedReleases []ReleaseSpec `yaml:"charts"`
|
||||
Namespace string `yaml:"namespace"`
|
||||
@@ -32,6 +33,11 @@ type HelmState struct {
|
||||
Releases []ReleaseSpec `yaml:"releases"`
|
||||
}
|
||||
|
||||
// HelmSpec to defines helmDefault values
|
||||
type HelmSpec struct {
|
||||
Args []string `yaml:"args"`
|
||||
}
|
||||
|
||||
// RepositorySpec that defines values for a helm repo
|
||||
type RepositorySpec struct {
|
||||
Name string `yaml:"name"`
|
||||
|
||||
Reference in New Issue
Block a user