From 8edf0316ec586fe25ae70389dc91789b8af166e0 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 3 Dec 2019 11:27:07 -0500 Subject: [PATCH 1/2] Address review comments from #1653 Adds tests for script preservation and args alongside scripts --- pkg/apis/pipeline/v1alpha1/merge_test.go | 22 ++++++++++++++++++++++ pkg/pod/script_test.go | 2 ++ 2 files changed, 24 insertions(+) diff --git a/pkg/apis/pipeline/v1alpha1/merge_test.go b/pkg/apis/pipeline/v1alpha1/merge_test.go index 5b159f548d1..fecccd86dec 100644 --- a/pkg/apis/pipeline/v1alpha1/merge_test.go +++ b/pkg/apis/pipeline/v1alpha1/merge_test.go @@ -100,6 +100,28 @@ func TestMergeStepsWithStepTemplate(t *testing.T) { Value: "NEW_VALUE", }}, }}}, + }, { + name: "merge-preserves-script", + template: &corev1.Container{ + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "bar", + }}, + }, + steps: []Step{{ + Script: "my-script", + Container: corev1.Container{Image: "image"}, + }}, + expected: []Step{{ + Script: "my-script", + Container: corev1.Container{ + Image: "image", + Env: []corev1.EnvVar{{ + Name: "FOO", + Value: "bar", + }}, + }, + }}, }} { t.Run(tc.name, func(t *testing.T) { result, err := MergeStepsWithStepTemplate(tc.template, tc.steps) diff --git a/pkg/pod/script_test.go b/pkg/pod/script_test.go index 8d4cb8b4d9b..d7a19d83345 100644 --- a/pkg/pod/script_test.go +++ b/pkg/pod/script_test.go @@ -66,6 +66,7 @@ func TestConvertScripts(t *testing.T) { Container: corev1.Container{ Image: "step-3", VolumeMounts: preExistingVolumeMounts, + Args: []string{"my", "args"}, }, }}) wantInit := &corev1.Container{ @@ -95,6 +96,7 @@ script-heredoc-randomly-generated-6nl7g }, { Image: "step-3", Command: []string{"/tekton/scripts/script-2-78c5n"}, + Args: []string{"my", "args"}, VolumeMounts: append(preExistingVolumeMounts, scriptsVolumeMount), }} if d := cmp.Diff(wantInit, gotInit); d != "" { From 183b79644f7accfcbeac4f79e2cbc5dcc6d48670 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 3 Dec 2019 12:36:57 -0500 Subject: [PATCH 2/2] Update script_test.go --- pkg/pod/script_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/pod/script_test.go b/pkg/pod/script_test.go index d7a19d83345..c5d7fcb2e97 100644 --- a/pkg/pod/script_test.go +++ b/pkg/pod/script_test.go @@ -66,7 +66,7 @@ func TestConvertScripts(t *testing.T) { Container: corev1.Container{ Image: "step-3", VolumeMounts: preExistingVolumeMounts, - Args: []string{"my", "args"}, + Args: []string{"my", "args"}, }, }}) wantInit := &corev1.Container{ @@ -96,7 +96,7 @@ script-heredoc-randomly-generated-6nl7g }, { Image: "step-3", Command: []string{"/tekton/scripts/script-2-78c5n"}, - Args: []string{"my", "args"}, + Args: []string{"my", "args"}, VolumeMounts: append(preExistingVolumeMounts, scriptsVolumeMount), }} if d := cmp.Diff(wantInit, gotInit); d != "" {