Skip to content
Snippets Groups Projects
Commit 32cece3f2c91 authored by Steeven Herlant's avatar Steeven Herlant
Browse files

add test for Helm chart's namespace

parent 58c871eb4e23
No related branches found
No related tags found
No related merge requests found
Pipeline #51864 passed
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
## Beaver config file ## Beaver config file
```yaml ```yaml
# Namespace used for this project # Default namespace used for this project
namespace: default namespace: default
# an inherited beaver project - which can also inherit another beaver project # an inherited beaver project - which can also inherit another beaver project
inherit: ../../base # path is relative to this beaver config file inherit: ../../base # path is relative to this beaver config file
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
type: helm # can be either helm or ytt type: helm # can be either helm or ytt
path: ../.vendor/helm/postgresql # path to your chart - relative to this file path: ../.vendor/helm/postgresql # path to your chart - relative to this file
name: pgsql # overwrite **helm** application name 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 # beaver variables that can be used inside your charts value files
# They are two methods # They are two methods
# First method : # First method :
......
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
c.MergeVariables(config) c.MergeVariables(config)
for k, chart := range config.Charts { for k, chart := range config.Charts {
c.Spec.Charts[k] = cmdChartFromChart(chart) c.Spec.Charts[k] = CmdChartFromChart(chart)
} }
for _, k := range config.Creates { for _, k := range config.Creates {
...@@ -385,7 +385,7 @@ ...@@ -385,7 +385,7 @@
return args, nil return args, nil
} }
func cmdChartFromChart(c Chart) CmdChart { func CmdChartFromChart(c Chart) CmdChart {
return CmdChart{ return CmdChart{
Type: c.Type, Type: c.Type,
Path: c.Path, Path: c.Path,
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
) )
var ( var (
fixtures = "fixtures/f1" fixtures = "fixtures/f1"
shaFixtures = "fixtures/f2" shaFixtures = "fixtures/f2"
helmNamespaceFixtures = "fixtures/f3"
) )
func TestConfig(t *testing.T) { func TestConfig(t *testing.T) {
...@@ -30,6 +31,22 @@ ...@@ -30,6 +31,22 @@
assert.Equal(t, "../vendor/ytt/odoo", config.Charts["odoo"].Path) 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) { func TestHydrate(t *testing.T) {
rawVariables := []byte(` rawVariables := []byte(`
#@data/values #@data/values
......
charts:
postgres1:
name: postgres1
type: helm
path: ../vendor/helm/postgresql1
namespace: custom-namespace
postgres2:
name: postgres2
type: helm
path: ../vendor/helm/postgresql2
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