feat(main): Support specifying kubectl args in ResourceSets

This commit is contained in:
Martin Lehmann 2018-11-15 13:49:23 +01:00 committed by Vincent Ambo
parent 5f433c46c1
commit 54db9785d6
6 changed files with 61 additions and 2 deletions

View file

@ -28,6 +28,9 @@ type ResourceSet struct {
// Values to include when interpolating resources from this resource set.
Values map[string]interface{} `json:"values"`
// Args to pass on to kubectl for this resource set.
Args []string `json:"args"`
// Nested resource sets to include
Include []ResourceSet `json:"include"`

View file

@ -54,6 +54,42 @@ func TestLoadFlatContextFromFile(t *testing.T) {
}
}
func TestLoadContextWithArgs(t *testing.T) {
ctx, err := LoadContext("testdata/flat-with-args-test.yaml", &noExplicitVars)
if err != nil {
t.Error(err)
t.Fail()
}
expected := Context{
Name: "k8s.prod.mydomain.com",
ResourceSets: []ResourceSet{
{
Name: "some-api",
Path: "some-api",
Values: make(map[string]interface{}, 0),
Args: []string{
"--as=some-user",
"--as-group=hello:world",
"--as-banana",
"true",
},
Include: nil,
Parent: "",
},
},
BaseDir: "testdata",
ImportedVars: make(map[string]interface{}, 0),
ExplicitVars: make(map[string]interface{}, 0),
}
if !reflect.DeepEqual(*ctx, expected) {
t.Error("Loaded context and expected context did not match")
t.Fail()
}
}
func TestLoadContextWithResourceSetCollections(t *testing.T) {
ctx, err := LoadContext("testdata/collections-test.yaml", &noExplicitVars)

View file

@ -0,0 +1,9 @@
---
context: k8s.prod.mydomain.com
include:
- name: some-api
args:
- --as=some-user
- --as-group=hello:world
- --as-banana
- "true"