Skip to content

Commit c898a7d

Browse files
authored
make local object reference a pointer so it can really be optional (#586)
1 parent df9cafb commit c898a7d

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

cmd/e2e/basic_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (f *TestStacksetSpecFactory) Create(t *testing.T, stackVersion string) zv1.
167167

168168
result.StackTemplate.Spec.ConfigurationResources = []zv1.ConfigurationResourcesSpec{
169169
{
170-
ConfigMapRef: corev1.LocalObjectReference{
170+
ConfigMapRef: &corev1.LocalObjectReference{
171171
Name: configMapName,
172172
},
173173
},
@@ -203,7 +203,7 @@ func (f *TestStacksetSpecFactory) Create(t *testing.T, stackVersion string) zv1.
203203

204204
result.StackTemplate.Spec.ConfigurationResources = []zv1.ConfigurationResourcesSpec{
205205
{
206-
SecretRef: corev1.LocalObjectReference{
206+
SecretRef: &corev1.LocalObjectReference{
207207
Name: secretName,
208208
},
209209
},

controller/stack_resources_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ func TestReconcileStackConfigMap(t *testing.T) {
963963
StackSpec: zv1.StackSpec{
964964
ConfigurationResources: []zv1.ConfigurationResourcesSpec{
965965
{
966-
ConfigMapRef: v1.LocalObjectReference{
966+
ConfigMapRef: &v1.LocalObjectReference{
967967
Name: "foo-v1-test-configmap",
968968
},
969969
},
@@ -976,12 +976,12 @@ func TestReconcileStackConfigMap(t *testing.T) {
976976
StackSpec: zv1.StackSpec{
977977
ConfigurationResources: []zv1.ConfigurationResourcesSpec{
978978
{
979-
ConfigMapRef: v1.LocalObjectReference{
979+
ConfigMapRef: &v1.LocalObjectReference{
980980
Name: "foo-v1-first-configmap",
981981
},
982982
},
983983
{
984-
ConfigMapRef: v1.LocalObjectReference{
984+
ConfigMapRef: &v1.LocalObjectReference{
985985
Name: "foo-v1-scnd-configmap",
986986
},
987987
},
@@ -1201,7 +1201,7 @@ func TestReconcileStackSecret(t *testing.T) {
12011201
StackSpec: zv1.StackSpec{
12021202
ConfigurationResources: []zv1.ConfigurationResourcesSpec{
12031203
{
1204-
SecretRef: v1.LocalObjectReference{
1204+
SecretRef: &v1.LocalObjectReference{
12051205
Name: "foo-v1-test-secret",
12061206
},
12071207
},
@@ -1214,12 +1214,12 @@ func TestReconcileStackSecret(t *testing.T) {
12141214
StackSpec: zv1.StackSpec{
12151215
ConfigurationResources: []zv1.ConfigurationResourcesSpec{
12161216
{
1217-
SecretRef: v1.LocalObjectReference{
1217+
SecretRef: &v1.LocalObjectReference{
12181218
Name: "foo-v1-test-secret",
12191219
},
12201220
},
12211221
{
1222-
ConfigMapRef: v1.LocalObjectReference{
1222+
ConfigMapRef: &v1.LocalObjectReference{
12231223
Name: "foo-v1-test-configmap",
12241224
},
12251225
},
@@ -1232,12 +1232,12 @@ func TestReconcileStackSecret(t *testing.T) {
12321232
StackSpec: zv1.StackSpec{
12331233
ConfigurationResources: []zv1.ConfigurationResourcesSpec{
12341234
{
1235-
SecretRef: v1.LocalObjectReference{
1235+
SecretRef: &v1.LocalObjectReference{
12361236
Name: "foo-v1-first-secret",
12371237
},
12381238
},
12391239
{
1240-
SecretRef: v1.LocalObjectReference{
1240+
SecretRef: &v1.LocalObjectReference{
12411241
Name: "foo-v1-scnd-secret",
12421242
},
12431243
},

pkg/apis/zalando.org/v1/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,10 @@ type StackSpec struct {
438438
// +k8s:deepcopy-gen=true
439439
type ConfigurationResourcesSpec struct {
440440
// ConfigMap to be owned by Stack
441-
ConfigMapRef v1.LocalObjectReference `json:"configMapRef,omitempty"`
441+
ConfigMapRef *v1.LocalObjectReference `json:"configMapRef,omitempty"`
442442

443443
// Secret to be owned by Stack
444-
SecretRef v1.LocalObjectReference `json:"secretRef,omitempty"`
444+
SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
445445
}
446446

447447
// GetName returns the name of the ConfigurationResourcesSpec.
@@ -459,12 +459,12 @@ func (crs *ConfigurationResourcesSpec) GetName() string {
459459

460460
// IsConfigMap returns true if the ConfigurationResourcesSpec is a ConfigMap.
461461
func (crs *ConfigurationResourcesSpec) IsConfigMap() bool {
462-
return crs.ConfigMapRef.Name != ""
462+
return crs.ConfigMapRef != nil
463463
}
464464

465465
// IsSecret returns true if the ConfigurationResourcesSpec is a Secret.
466466
func (crs *ConfigurationResourcesSpec) IsSecret() bool {
467-
return crs.SecretRef.Name != ""
467+
return crs.SecretRef != nil
468468
}
469469

470470
// StackSpecInternal is the spec part of the Stack, including `ingress` and

pkg/apis/zalando.org/v1/zz_generated.deepcopy.go

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)