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:
parent
af1914c575
commit
58bc2a2997
35
main.go
35
main.go
|
|
@ -70,9 +70,9 @@ func main() {
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||||
args := c.String("args")
|
args := getArgs(c, state)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
helm.SetExtraArgs(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.SyncRepos(helm)
|
return state.SyncRepos(helm)
|
||||||
|
|
@ -100,9 +100,9 @@ func main() {
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||||
args := c.String("args")
|
args := getArgs(c, state)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
helm.SetExtraArgs(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
values := c.StringSlice("values")
|
values := c.StringSlice("values")
|
||||||
|
|
@ -137,9 +137,9 @@ func main() {
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||||
args := c.String("args")
|
args := getArgs(c, state)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
helm.SetExtraArgs(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Bool("sync-repos") {
|
if c.Bool("sync-repos") {
|
||||||
|
|
@ -217,9 +217,9 @@ func main() {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
args := c.String("args")
|
args := getArgs(c, state)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
helm.SetExtraArgs(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
values := c.StringSlice("values")
|
values := c.StringSlice("values")
|
||||||
|
|
@ -248,9 +248,9 @@ func main() {
|
||||||
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
return eachDesiredStateDo(c, func(state *state.HelmState, helm helmexec.Interface) []error {
|
||||||
workers := c.Int("concurrency")
|
workers := c.Int("concurrency")
|
||||||
|
|
||||||
args := c.String("args")
|
args := getArgs(c, state)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
helm.SetExtraArgs(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.ReleaseStatuses(helm, workers)
|
return state.ReleaseStatuses(helm, workers)
|
||||||
|
|
@ -298,9 +298,9 @@ func main() {
|
||||||
cleanup := c.Bool("cleanup")
|
cleanup := c.Bool("cleanup")
|
||||||
timeout := c.Int("timeout")
|
timeout := c.Int("timeout")
|
||||||
|
|
||||||
args := c.String("args")
|
args := getArgs(c, state)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
helm.SetExtraArgs(strings.Split(args, " ")...)
|
helm.SetExtraArgs(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.TestReleases(helm, cleanup, timeout)
|
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.")
|
log.Printf("err: Cannot use option --kube-context and set attribute context.")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeContext = st.Context
|
kubeContext = st.Context
|
||||||
}
|
}
|
||||||
if namespace != "" {
|
if namespace != "" {
|
||||||
|
|
@ -417,6 +418,7 @@ func loadDesiredStateFromFile(c *cli.Context, file string) (*state.HelmState, he
|
||||||
}
|
}
|
||||||
st.Namespace = namespace
|
st.Namespace = namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(labels) > 0 {
|
if len(labels) > 0 {
|
||||||
err = st.FilterReleases(labels)
|
err = st.FilterReleases(labels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -459,3 +461,12 @@ func clean(state *state.HelmState, errs []error) error {
|
||||||
}
|
}
|
||||||
return nil
|
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
|
// HelmState structure for the helmfile
|
||||||
type HelmState struct {
|
type HelmState struct {
|
||||||
BaseChartPath string
|
BaseChartPath string
|
||||||
|
HelmDefaults HelmSpec `yaml:"helmDefaults"`
|
||||||
Context string `yaml:"context"`
|
Context string `yaml:"context"`
|
||||||
DeprecatedReleases []ReleaseSpec `yaml:"charts"`
|
DeprecatedReleases []ReleaseSpec `yaml:"charts"`
|
||||||
Namespace string `yaml:"namespace"`
|
Namespace string `yaml:"namespace"`
|
||||||
|
|
@ -32,6 +33,11 @@ type HelmState struct {
|
||||||
Releases []ReleaseSpec `yaml:"releases"`
|
Releases []ReleaseSpec `yaml:"releases"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HelmSpec to defines helmDefault values
|
||||||
|
type HelmSpec struct {
|
||||||
|
Args []string `yaml:"args"`
|
||||||
|
}
|
||||||
|
|
||||||
// RepositorySpec that defines values for a helm repo
|
// RepositorySpec that defines values for a helm repo
|
||||||
type RepositorySpec struct {
|
type RepositorySpec struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue