Skip to content

Commit ac7b57a

Browse files
Priya Wadhwatekton-robot
authored andcommitted
Fix unit test & comment out default settings in deployment.yaml
1 parent 1b1a4a8 commit ac7b57a

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

config/100-deployment.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ metadata:
3535
app.kubernetes.io/part-of: tekton-pipelines
3636
pipeline.tekton.dev/release: "devel"
3737
version: "devel"
38-
# The data can be tweaked at install time.
39-
data:
40-
artifacts.taskrun.format: tekton
41-
artifacts.taskrun.storage: tekton
42-
artifacts.taskrun.signer: x509
43-
artifacts.oci.storage: oci
44-
artifacts.oci.format: simplesigning
45-
artifacts.oci.signer: x509
38+
# The data can be tweaked at install time, it is commented out
39+
# because these are the default settings.
40+
# data:
41+
# artifacts.taskrun.format: tekton
42+
# artifacts.taskrun.storage: tekton
43+
# artifacts.taskrun.signer: x509
44+
# artifacts.oci.storage: oci
45+
# artifacts.oci.format: simplesigning
46+
# artifacts.oci.signer: x509
4647
---
4748
apiVersion: apps/v1
4849
kind: Deployment

pkg/config/store_test.go

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestNewConfigStore(t *testing.T) {
3636

3737
// Setup some config
3838
cm.Data = map[string]string{}
39-
cm.Data[taskrunFormatKey] = "foo"
39+
cm.Data[taskrunSignerKey] = "pgp"
4040

4141
if cm, err = fakekubeclient.CoreV1().ConfigMaps(ns).Update(ctx, cm, metav1.UpdateOptions{}); err != nil {
4242
t.Errorf("error updating configmap: %v", err)
@@ -45,24 +45,24 @@ func TestNewConfigStore(t *testing.T) {
4545
// It should be updated by then...
4646
time.Sleep(100 * time.Millisecond)
4747
// Test that the values are set!
48-
if diff := cmp.Diff("foo", cs.Config().Artifacts.TaskRuns.Format); diff != "" {
48+
if diff := cmp.Diff("pgp", cs.Config().Artifacts.TaskRuns.Signer); diff != "" {
4949
t.Error(diff)
5050
}
5151

5252
// Change it again
53-
cm.Data[taskrunFormatKey] = "bar"
53+
cm.Data[taskrunSignerKey] = "kms"
5454

5555
if _, err := fakekubeclient.CoreV1().ConfigMaps(ns).Update(ctx, cm, metav1.UpdateOptions{}); err != nil {
5656
t.Errorf("error updating configmap: %v", err)
5757
}
5858
time.Sleep(100 * time.Millisecond)
5959
// Test that the values are set!
60-
if diff := cmp.Diff("bar", cs.Config().Artifacts.TaskRuns.Format); diff != "" {
60+
if diff := cmp.Diff("kms", cs.Config().Artifacts.TaskRuns.Signer); diff != "" {
6161
t.Error(diff)
6262
}
6363
}
6464

65-
func Test_parse(t *testing.T) {
65+
func TestParse(t *testing.T) {
6666
tests := []struct {
6767
name string
6868
data map[string]string
@@ -73,30 +73,51 @@ func Test_parse(t *testing.T) {
7373
data: map[string]string{},
7474
want: Config{
7575
Artifacts: ArtifactConfigs{
76-
TaskRuns: Artifact{},
76+
TaskRuns: Artifact{
77+
Format: "tekton",
78+
StorageBackend: "tekton",
79+
Signer: "x509",
80+
},
81+
OCI: Artifact{
82+
Format: "simplesigning",
83+
StorageBackend: "oci",
84+
Signer: "x509",
85+
},
7786
},
7887
},
7988
},
8089
{
8190
name: "single",
82-
data: map[string]string{taskrunFormatKey: "foo"},
91+
data: map[string]string{taskrunSignerKey: "pgp"},
8392
want: Config{
8493
Artifacts: ArtifactConfigs{
8594
TaskRuns: Artifact{
86-
Format: "foo",
87-
StorageBackend: "",
95+
Format: "tekton",
96+
Signer: "pgp",
97+
StorageBackend: "tekton",
98+
},
99+
OCI: Artifact{
100+
Format: "simplesigning",
101+
StorageBackend: "oci",
102+
Signer: "x509",
88103
},
89104
},
90105
},
91106
},
92107
{
93108
name: "extra",
94-
data: map[string]string{taskrunFormatKey: "foo", "other-key": "foo"},
109+
data: map[string]string{taskrunSignerKey: "pgp", "other-key": "foo"},
95110
want: Config{
96111
Artifacts: ArtifactConfigs{
97112
TaskRuns: Artifact{
98-
Format: "foo",
99-
StorageBackend: "",
113+
Format: "tekton",
114+
Signer: "pgp",
115+
StorageBackend: "tekton",
116+
},
117+
OCI: Artifact{
118+
Format: "simplesigning",
119+
StorageBackend: "oci",
120+
Signer: "x509",
100121
},
101122
},
102123
},

test/test_utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ func setConfigMap(ctx context.Context, t *testing.T, c *clients, data map[string
173173
oldData[k] = v
174174
}
175175

176+
if cm.Data == nil {
177+
cm.Data = map[string]string{}
178+
}
179+
176180
for k, v := range data {
177181
cm.Data[k] = v
178182
}

0 commit comments

Comments
 (0)