Allow specifying a default namespace used across all the releases (#39)

* Allow specifying a default namespace used across all the releases

Omit `namespace` in `charts[].namespace` of charts.yaml and then run `helmfile sync -n yourns` to install your charts into `yourns`.

Resolves #31
This commit is contained in:
KUOKA Yusuke
2018-03-01 23:09:02 +09:00
committed by GitHub
parent f02790d566
commit efdede1658
2 changed files with 20 additions and 2 deletions
+8 -2
View File
@@ -21,6 +21,7 @@ import (
type HelmState struct {
BaseChartPath string
Context string `yaml:"context"`
Namespace string `yaml:"namespace"`
Repositories []RepositorySpec `yaml:"repositories"`
Charts []ChartSpec `yaml:"charts"`
}
@@ -99,6 +100,11 @@ func renderTemplateString(s string) (string, error) {
return tplString.String(), nil
}
func (state *HelmState) applyDefaultsTo(spec ChartSpec) ChartSpec {
spec.Namespace = state.Namespace
return spec
}
func (state *HelmState) SyncRepos(helm helmexec.Interface) []error {
var wg sync.WaitGroup
errs := []error{}
@@ -137,8 +143,8 @@ func (state *HelmState) SyncCharts(helm helmexec.Interface, additonalValues []st
for w := 1; w <= workerLimit; w++ {
go func() {
for chart := range jobQueue {
flags, flagsErr := flagsForChart(state.BaseChartPath, &chart)
chartWithDefaults := state.applyDefaultsTo(chart)
flags, flagsErr := flagsForChart(state.BaseChartPath, &chartWithDefaults)
if flagsErr != nil {
errQueue <- flagsErr
doneQueue <- true