Skip to content

Commit 92c7eb2

Browse files
authored
Add List Maps to CRD (#69)
This ensures that lists of things have unique entries, or for the most part, unique names and IDs. Not perfect, but an improvement none the less.
1 parent f2e1a7d commit 92c7eb2

File tree

4 files changed

+54
-28
lines changed

4 files changed

+54
-28
lines changed

crds/servicebroker.couchbase.com_servicebrokerconfigs.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ spec:
124124
- name
125125
type: object
126126
type: array
127+
x-kubernetes-list-map-keys:
128+
- name
129+
x-kubernetes-list-type: map
127130
registry:
128131
description: Registry allows the pre-calculation of dynamic
129132
configuration from request inputs i.e. registry or parameters,
@@ -145,12 +148,16 @@ spec:
145148
- value
146149
type: object
147150
type: array
151+
x-kubernetes-list-map-keys:
152+
- name
153+
x-kubernetes-list-type: map
148154
templates:
149155
description: Templates defines all the templates that will
150156
be created, in order, by the service broker for this operation.
151157
items:
152158
type: string
153159
type: array
160+
x-kubernetes-list-type: set
154161
type: object
155162
serviceInstance:
156163
description: ServiceInstance defines the set of templates to
@@ -210,6 +217,9 @@ spec:
210217
- name
211218
type: object
212219
type: array
220+
x-kubernetes-list-map-keys:
221+
- name
222+
x-kubernetes-list-type: map
213223
registry:
214224
description: Registry allows the pre-calculation of dynamic
215225
configuration from request inputs i.e. registry or parameters,
@@ -231,12 +241,16 @@ spec:
231241
- value
232242
type: object
233243
type: array
244+
x-kubernetes-list-map-keys:
245+
- name
246+
x-kubernetes-list-type: map
234247
templates:
235248
description: Templates defines all the templates that will
236249
be created, in order, by the service broker for this operation.
237250
items:
238251
type: string
239252
type: array
253+
x-kubernetes-list-type: set
240254
type: object
241255
required:
242256
- name
@@ -246,6 +260,9 @@ spec:
246260
type: object
247261
minItems: 1
248262
type: array
263+
x-kubernetes-list-map-keys:
264+
- name
265+
x-kubernetes-list-type: map
249266
catalog:
250267
description: 'Catalog is the Open Service Broker service catalog definition.
251268
More info: https://github.com/couchbase/service-broker/tree/master/documentation/modules/ROOT/pages/concepts/catalog.adoc'
@@ -437,6 +454,9 @@ spec:
437454
type: object
438455
minItems: 1
439456
type: array
457+
x-kubernetes-list-map-keys:
458+
- name
459+
x-kubernetes-list-type: map
440460
requires:
441461
description: Requires is a list of permissions that the
442462
user would have to give the service, if they provision
@@ -449,6 +469,7 @@ spec:
449469
items:
450470
type: string
451471
type: array
472+
x-kubernetes-list-type: set
452473
tags:
453474
description: Tags provide a flexible mechanism to expose
454475
a classification, attribute, or base technology of a service,
@@ -459,6 +480,7 @@ spec:
459480
items:
460481
type: string
461482
type: array
483+
x-kubernetes-list-type: set
462484
required:
463485
- bindable
464486
- description
@@ -468,6 +490,9 @@ spec:
468490
type: object
469491
minItems: 1
470492
type: array
493+
x-kubernetes-list-map-keys:
494+
- name
495+
x-kubernetes-list-type: map
471496
required:
472497
- services
473498
type: object
@@ -499,6 +524,9 @@ spec:
499524
- template
500525
type: object
501526
type: array
527+
x-kubernetes-list-map-keys:
528+
- name
529+
x-kubernetes-list-type: map
502530
required:
503531
- bindings
504532
- catalog

pkg/apis/servicebroker/v1alpha1/types.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ type ServiceBrokerConfigSpec struct {
5353

5454
// Templates is a set of resource templates that can be rendered by the service broker. More info:
5555
// https://github.com/couchbase/service-broker/tree/master/documentation/modules/ROOT/pages/concepts/templates.adoc
56+
// +listType=map
57+
// +listMapKey=name
5658
Templates []ConfigurationTemplate `json:"templates"`
5759

5860
// Bindings is a set of bindings that link service plans to resource templates. More info:
5961
// https://github.com/couchbase/service-broker/tree/master/documentation/modules/ROOT/pages/concepts/bindings.adoc
6062
// +kubebuilder:validation:MinItems=1
63+
// +listType=map
64+
// +listMapKey=name
6165
Bindings []ConfigurationBinding `json:"bindings"`
6266
}
6367

@@ -67,6 +71,8 @@ type ServiceCatalog struct {
6771
// Services is an array of Service Offering objects. More info:
6872
// https://github.com/couchbase/service-broker/tree/master/documentation/modules/ROOT/pages/concepts/catalog.adoc#service-offerings
6973
// +kubebuilder:validation:MinItems=1
74+
// +listType=map
75+
// +listMapKey=name
7076
Services []ServiceOffering `json:"services"`
7177
}
7278

@@ -94,11 +100,13 @@ type ServiceOffering struct {
94100
// technology of a service, enabling equivalent services to be swapped out without changes
95101
// to dependent logic in applications, buildpacks, or other services. E.g. mysql, relational,
96102
// redis, key-value, caching, messaging, amqp.
103+
// +listType=set
97104
Tags []string `json:"tags,omitempty"`
98105

99106
// Requires is a list of permissions that the user would have to give the service, if they provision
100107
// it. The only permissions currently supported are syslog_drain, route_forwarding and volume_mount.
101108
// +kubebuilder:validation:Enum=syslog_drain;route_forwarding;volume_mount
109+
// +listType=set
102110
Requires []string `json:"requires,omitempty"`
103111

104112
// Bindable specifies whether Service Instances of the service can be bound to applications. This
@@ -126,6 +134,8 @@ type ServiceOffering struct {
126134
// contain at least one Service Plan. More info:
127135
// https://github.com/couchbase/service-broker/tree/master/documentation/modules/ROOT/pages/concepts/catalog.adoc#service-plans
128136
// +kubebuilder:validation:MinItems=1
137+
// +listType=map
138+
// +listMapKey=name
129139
Plans []ServicePlan `json:"plans"`
130140
}
131141

@@ -286,20 +296,23 @@ type ConfigurationBinding struct {
286296
type ServiceBrokerTemplateList struct {
287297
// Registry allows the pre-calculation of dynamic configuration from
288298
// request inputs i.e. registry or parameters, or generated e.g. passwords.
299+
// +listType=map
300+
// +listMapKey=name
289301
Registry []RegistryValue `json:"registry,omitempty"`
290302

291303
// Templates defines all the templates that will be created, in order,
292304
// by the service broker for this operation.
305+
// +listType=set
293306
Templates []string `json:"templates,omitempty"`
294307

295308
// ReadinessChecks defines a set of tests that define whether a service instance
296309
// or service binding is actually ready as reported by the service broker polling
297310
// API.
298-
ReadinessChecks ConfigurationReadinessCheckList `json:"readinessChecks,omitempty"`
311+
// +listType=map
312+
// +listMapKey=name
313+
ReadinessChecks []ConfigurationReadinessCheck `json:"readinessChecks,omitempty"`
299314
}
300315

301-
type ConfigurationReadinessCheckList []ConfigurationReadinessCheck
302-
303316
// ConfigurationReadinessCheck is a readiness check to perform on a service instance
304317
// or binding before declaring it ready and provisioning has completed.
305318
type ConfigurationReadinessCheck struct {

pkg/apis/servicebroker/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/fixtures/fixtures.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ var (
212212

213213
// basicReadinessChecks are used to check the test resource created by our
214214
// service instance is ready.
215-
basicReadinessChecks = v1.ConfigurationReadinessCheckList{
215+
basicReadinessChecks = []v1.ConfigurationReadinessCheck{
216216
{
217217
Name: "pod-ready",
218218
Condition: &v1.ConfigurationReadinessCheckCondition{
@@ -313,7 +313,14 @@ func BasicConfiguration() *v1.ServiceBrokerConfigSpec {
313313
// check added for the resource that is templated.
314314
func BasicConfigurationWithReadiness() *v1.ServiceBrokerConfigSpec {
315315
configuration := BasicConfiguration()
316-
configuration.Bindings[0].ServiceInstance.ReadinessChecks = basicReadinessChecks.DeepCopy()
316+
317+
checks := []v1.ConfigurationReadinessCheck{}
318+
319+
for _, check := range basicReadinessChecks {
320+
checks = append(checks, *check.DeepCopy())
321+
}
322+
323+
configuration.Bindings[0].ServiceInstance.ReadinessChecks = checks
317324

318325
return configuration
319326
}

0 commit comments

Comments
 (0)