diff --git a/README.md b/README.md index 58c871eb4e233b7cdafaf903d2e00657bbb3e70d_UkVBRE1FLm1k..32cece3f2c91f99954e8624f8f65aa7b833b654b_UkVBRE1FLm1k 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ ## Beaver config file ```yaml -# Namespace used for this project +# Default namespace used for this project namespace: default # an inherited beaver project - which can also inherit another beaver project inherit: ../../base # path is relative to this beaver config file @@ -55,6 +55,8 @@ type: helm # can be either helm or ytt path: ../.vendor/helm/postgresql # path to your chart - relative to this file name: pgsql # overwrite **helm** application name + # Keyword `namespace` only available for Helm charts + namespace: my-namespace # Set namespace only for the current chart(Optional) # beaver variables that can be used inside your charts value files # They are two methods # First method : diff --git a/runner/config.go b/runner/config.go index 58c871eb4e233b7cdafaf903d2e00657bbb3e70d_cnVubmVyL2NvbmZpZy5nbw==..32cece3f2c91f99954e8624f8f65aa7b833b654b_cnVubmVyL2NvbmZpZy5nbw== 100644 --- a/runner/config.go +++ b/runner/config.go @@ -163,7 +163,7 @@ c.MergeVariables(config) for k, chart := range config.Charts { - c.Spec.Charts[k] = cmdChartFromChart(chart) + c.Spec.Charts[k] = CmdChartFromChart(chart) } for _, k := range config.Creates { @@ -385,7 +385,7 @@ return args, nil } -func cmdChartFromChart(c Chart) CmdChart { +func CmdChartFromChart(c Chart) CmdChart { return CmdChart{ Type: c.Type, Path: c.Path, diff --git a/runner/config_test.go b/runner/config_test.go index 58c871eb4e233b7cdafaf903d2e00657bbb3e70d_cnVubmVyL2NvbmZpZ190ZXN0Lmdv..32cece3f2c91f99954e8624f8f65aa7b833b654b_cnVubmVyL2NvbmZpZ190ZXN0Lmdv 100644 --- a/runner/config_test.go +++ b/runner/config_test.go @@ -16,8 +16,9 @@ ) var ( - fixtures = "fixtures/f1" - shaFixtures = "fixtures/f2" + fixtures = "fixtures/f1" + shaFixtures = "fixtures/f2" + helmNamespaceFixtures = "fixtures/f3" ) func TestConfig(t *testing.T) { @@ -30,6 +31,22 @@ assert.Equal(t, "../vendor/ytt/odoo", config.Charts["odoo"].Path) } +func TestBuildArgs(t *testing.T) { + config, err := runner.NewConfig(filepath.Join(helmNamespaceFixtures, "base")) + require.NoError(t, err) + + for _, chart := range config.Charts { + cmdChart := runner.CmdChartFromChart(chart) + result, err := cmdChart.BuildArgs("my-name", "my-namespace") + require.NoError(t, err) + if cmdChart.Namespace != "" { + assert.Equal(t, cmdChart.Namespace, result[4]) + } else { + assert.Equal(t, "my-namespace", result[4]) + } + } +} + func TestHydrate(t *testing.T) { rawVariables := []byte(` #@data/values diff --git a/runner/fixtures/f3/base/beaver.yml b/runner/fixtures/f3/base/beaver.yml new file mode 100644 index 0000000000000000000000000000000000000000..32cece3f2c91f99954e8624f8f65aa7b833b654b_cnVubmVyL2ZpeHR1cmVzL2YzL2Jhc2UvYmVhdmVyLnltbA== --- /dev/null +++ b/runner/fixtures/f3/base/beaver.yml @@ -0,0 +1,10 @@ +charts: + postgres1: + name: postgres1 + type: helm + path: ../vendor/helm/postgresql1 + namespace: custom-namespace + postgres2: + name: postgres2 + type: helm + path: ../vendor/helm/postgresql2