Skip to content

Commit cce39bf

Browse files
committed
Add schema validation for CRDs
Signed-off-by: Scott Andrews <[email protected]>
1 parent 3f649ce commit cce39bf

File tree

2 files changed

+318
-14
lines changed

2 files changed

+318
-14
lines changed

config/300-provisionedservice.yaml

+94-7
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,104 @@ spec:
1313
version: v1alpha1
1414
names:
1515
kind: ProvisionedService
16+
listKind: ProvisionedServiceList
1617
plural: provisionedservices
1718
singular: provisionedservice
1819
categories:
19-
- all
20+
- all
21+
- bind
2022
scope: Namespaced
2123
subresources:
2224
status: {}
2325
additionalPrinterColumns:
24-
- name: Ready
25-
type: string
26-
JSONPath: ".status.conditions[?(@.type=='Ready')].status"
27-
- name: Reason
28-
type: string
29-
JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
26+
- JSONPath: .status.conditions[?(@.type=="Ready")].status
27+
name: Ready
28+
type: string
29+
- JSONPath: .status.conditions[?(@.type=="Ready")].reason
30+
name: Reason
31+
type: string
32+
- JSONPath: .metadata.creationTimestamp
33+
name: Age
34+
type: date
35+
validation:
36+
openAPIV3Schema:
37+
description: ProvisionedService exposes an existing Secret as a Service for binding
38+
via a ServiceBinding
39+
properties:
40+
apiVersion:
41+
description: 'APIVersion defines the versioned schema of this representation
42+
of an object. Servers should convert recognized schemas to the latest
43+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
44+
type: string
45+
kind:
46+
description: 'Kind is a string value representing the REST resource this
47+
object represents. Servers may infer this from the endpoint the client
48+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
49+
type: string
50+
metadata:
51+
type: object
52+
spec:
53+
description: ProvisionedServiceSpec defines the desired state of ProvisionedService
54+
properties:
55+
binding:
56+
description: Binding exposes the secret for this service
57+
properties:
58+
name:
59+
description: 'Name of the referent secret. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
60+
type: string
61+
required:
62+
- name
63+
type: object
64+
required:
65+
- binding
66+
type: object
67+
status:
68+
description: ProvisionedServiceStatus defines the observed state of ProvisionedService
69+
properties:
70+
binding:
71+
description: Binding exposes the secret for this service
72+
properties:
73+
name:
74+
description: 'Name of the referent secret. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
75+
type: string
76+
required:
77+
- name
78+
type: object
79+
conditions:
80+
description: Conditions are the conditions of this ProvisionedService
81+
items:
82+
description: Condition contains details for the current condition of
83+
this ProvisionedService
84+
properties:
85+
lastTransitionTime:
86+
description: Last time the condition transitioned from one status
87+
to another
88+
format: date-time
89+
type: string
90+
message:
91+
description: Human-readable message indicating details about last
92+
transition
93+
type: string
94+
reason:
95+
description: Unique, one-word, CamelCase reason for the condition's
96+
last transition
97+
type: string
98+
status:
99+
description: Status is the status of the condition Can be True,
100+
False, Unknown.
101+
type: string
102+
type:
103+
description: Type is the type of the condition
104+
type: string
105+
required:
106+
- status
107+
- type
108+
type: object
109+
type: array
110+
observedGeneration:
111+
description: ObservedGeneration is the 'Generation' of the ProvisionedService
112+
that was last processed by the controller.
113+
format: int64
114+
type: integer
115+
type: object
116+
type: object

config/300-servicebinding.yaml

+224-7
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,234 @@ spec:
1414
version: v1alpha2
1515
names:
1616
kind: ServiceBinding
17+
listKind: ServiceBindingList
1718
plural: servicebindings
1819
singular: servicebinding
1920
categories:
20-
- all
21+
- all
22+
- bind
2123
scope: Namespaced
2224
subresources:
2325
status: {}
2426
additionalPrinterColumns:
25-
- name: Ready
26-
type: string
27-
JSONPath: ".status.conditions[?(@.type=='Ready')].status"
28-
- name: Reason
29-
type: string
30-
JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
27+
- JSONPath: .status.conditions[?(@.type=="Ready")].status
28+
name: Ready
29+
type: string
30+
- JSONPath: .status.conditions[?(@.type=="Ready")].reason
31+
name: Reason
32+
type: string
33+
- JSONPath: .metadata.creationTimestamp
34+
name: Age
35+
type: date
36+
validation:
37+
openAPIV3Schema:
38+
description: ServiceBinding is the Schema for the servicebindings API
39+
properties:
40+
apiVersion:
41+
description: 'APIVersion defines the versioned schema of this representation
42+
of an object. Servers should convert recognized schemas to the latest
43+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
44+
type: string
45+
kind:
46+
description: 'Kind is a string value representing the REST resource this
47+
object represents. Servers may infer this from the endpoint the client
48+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
49+
type: string
50+
metadata:
51+
type: object
52+
spec:
53+
description: ServiceBindingSpec defines the desired state of ServiceBinding
54+
properties:
55+
application:
56+
description: Application is a reference to an object that fulfills the
57+
PodSpec duck type
58+
properties:
59+
apiVersion:
60+
description: API version of the referent.
61+
type: string
62+
containers:
63+
description: Containers describes which containers in a Pod should
64+
be bound to
65+
items:
66+
anyOf:
67+
- type: integer
68+
- type: string
69+
x-kubernetes-int-or-string: true
70+
type: array
71+
kind:
72+
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
73+
type: string
74+
name:
75+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
76+
type: string
77+
selector:
78+
description: Selector is a query that selects the application or
79+
applications to bind the service to
80+
properties:
81+
matchExpressions:
82+
description: matchExpressions is a list of label selector requirements.
83+
The requirements are ANDed.
84+
items:
85+
description: A label selector requirement is a selector that
86+
contains values, a key, and an operator that relates the
87+
key and values.
88+
properties:
89+
key:
90+
description: key is the label key that the selector applies
91+
to.
92+
type: string
93+
operator:
94+
description: operator represents a key's relationship
95+
to a set of values. Valid operators are In, NotIn, Exists
96+
and DoesNotExist.
97+
type: string
98+
values:
99+
description: values is an array of string values. If the
100+
operator is In or NotIn, the values array must be non-empty.
101+
If the operator is Exists or DoesNotExist, the values
102+
array must be empty. This array is replaced during a
103+
strategic merge patch.
104+
items:
105+
type: string
106+
type: array
107+
required:
108+
- key
109+
- operator
110+
type: object
111+
type: array
112+
matchLabels:
113+
additionalProperties:
114+
type: string
115+
description: matchLabels is a map of {key,value} pairs. A single
116+
{key,value} in the matchLabels map is equivalent to an element
117+
of matchExpressions, whose key field is "key", the operator
118+
is "In", and the values array contains only "value". The requirements
119+
are ANDed.
120+
type: object
121+
type: object
122+
required:
123+
- apiVersion
124+
- kind
125+
type: object
126+
env:
127+
description: EnvVars is the collection of mappings from Secret entries
128+
to environment variables
129+
items:
130+
description: ServiceBindingEnvVar defines a mapping from the value
131+
of a Secret entry to an environment variable
132+
properties:
133+
key:
134+
description: Key is the key in the Secret that will be exposed
135+
type: string
136+
name:
137+
description: Name is the name of the environment variable
138+
type: string
139+
required:
140+
- key
141+
- name
142+
type: object
143+
type: array
144+
mappings:
145+
description: Mappings is the collection of mappings from existing Secret
146+
entries to new Secret entries
147+
items:
148+
description: ServiceBindingMapping defines a mapping from the existing
149+
collection of Secret values to a new Secret entry.
150+
properties:
151+
name:
152+
description: Name is the name of the mapped Secret entry
153+
type: string
154+
value:
155+
description: Value is the value of the new Secret entry. Contents
156+
may be a Go template and refer to the other secret entries by
157+
name.
158+
type: string
159+
required:
160+
- name
161+
- value
162+
type: object
163+
type: array
164+
name:
165+
description: Name is the name of the service as projected into the application
166+
container. Defaults to .metadata.name.
167+
type: string
168+
provider:
169+
description: Provider is the provider of the service as projected into
170+
the application container
171+
type: string
172+
service:
173+
description: Service is a reference to an object that fulfills the ProvisionedService
174+
duck type
175+
properties:
176+
apiVersion:
177+
description: API version of the referent.
178+
type: string
179+
kind:
180+
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
181+
type: string
182+
name:
183+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
184+
type: string
185+
required:
186+
- apiVersion
187+
- kind
188+
- name
189+
type: object
190+
type:
191+
description: Type is the type of the service as projected into the application
192+
container
193+
type: string
194+
required:
195+
- application
196+
- service
197+
type: object
198+
status:
199+
description: ServiceBindingStatus defines the observed state of ServiceBinding
200+
properties:
201+
binding:
202+
description: Binding exposes the projected secret for this ServiceBinding
203+
properties:
204+
name:
205+
description: 'Name of the referent secret. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
206+
type: string
207+
required:
208+
- name
209+
type: object
210+
conditions:
211+
description: Conditions are the conditions of this ServiceBinding
212+
items:
213+
description: ServiceBindingCondition contains details for the current
214+
condition of this ServiceBinding
215+
properties:
216+
lastTransitionTime:
217+
description: Last time the condition transitioned from one status
218+
to another
219+
format: date-time
220+
type: string
221+
message:
222+
description: Human-readable message indicating details about last
223+
transition
224+
type: string
225+
reason:
226+
description: Unique, one-word, CamelCase reason for the condition's
227+
last transition
228+
type: string
229+
status:
230+
description: Status is the status of the condition Can be True,
231+
False, Unknown.
232+
type: string
233+
type:
234+
description: Type is the type of the condition
235+
type: string
236+
required:
237+
- status
238+
- type
239+
type: object
240+
type: array
241+
observedGeneration:
242+
description: ObservedGeneration is the 'Generation' of the ServiceBinding
243+
that was last processed by the controller.
244+
format: int64
245+
type: integer
246+
type: object
247+
type: object

0 commit comments

Comments
 (0)