feat(main): Support specifying kubectl args in ResourceSets
This commit is contained in:
parent
5f433c46c1
commit
54db9785d6
6 changed files with 61 additions and 2 deletions
|
|
@ -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"`
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
9
context/testdata/flat-with-args-test.yaml
vendored
Normal file
9
context/testdata/flat-with-args-test.yaml
vendored
Normal 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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue