about summary refs log tree commit diff
path: root/context
diff options
context:
space:
mode:
authorMartin Lehmann <martin@folio.no>2018-11-15T12·49+0100
committerVincent Ambo <github@tazj.in>2018-12-11T09·58+0100
commit54db9785d65d8a9dfc78d1cf230810b19f1abffb (patch)
treefcbfd470aaf794ca21bcd2a5ccc1a9dac66a3c12 /context
parent5f433c46c16f4466ad17578eb1762399aa7746d1 (diff)
feat(main): Support specifying kubectl args in ResourceSets
Diffstat (limited to 'context')
-rw-r--r--context/context.go3
-rw-r--r--context/context_test.go36
-rw-r--r--context/testdata/flat-with-args-test.yaml9
3 files changed, 48 insertions, 0 deletions
diff --git a/context/context.go b/context/context.go
index 49de7f46957a..314fc3584545 100644
--- a/context/context.go
+++ b/context/context.go
@@ -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"`
 
diff --git a/context/context_test.go b/context/context_test.go
index 34c77cc9b7c6..d7fdc11e5718 100644
--- a/context/context_test.go
+++ b/context/context_test.go
@@ -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)
 
diff --git a/context/testdata/flat-with-args-test.yaml b/context/testdata/flat-with-args-test.yaml
new file mode 100644
index 000000000000..29d3334fb54d
--- /dev/null
+++ b/context/testdata/flat-with-args-test.yaml
@@ -0,0 +1,9 @@
+---
+context: k8s.prod.mydomain.com
+include:
+  - name: some-api
+    args:
+      - --as=some-user
+      - --as-group=hello:world
+      - --as-banana
+      - "true"