Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit a47043e

Browse files
author
Pablo Mercado
authored
Merge pull request #138 from triggermesh/task/add-spec-to-volumes
Render: add spec to volumes to API
2 parents 079f008 + 991e884 commit a47043e

File tree

19 files changed

+767
-439
lines changed

19 files changed

+767
-439
lines changed

config/300-crdregistration.yaml

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ spec:
155155
transformed into workload parameters.
156156
properties:
157157
addEnvs:
158-
description: AddEnvs contains configurations for parameters
159-
to be added to the workload not derived from the user instance.
158+
description: AddEnvs contains instructions to create environment
159+
variables at the workload not derived from the user instance.
160160
items:
161161
description: EnvVar represents an environment variable present
162162
in a Container.
@@ -273,28 +273,21 @@ spec:
273273
- name
274274
type: object
275275
type: array
276-
global:
277-
description: Global defines the configuration to be applied
278-
to all generated parameters.
279-
properties:
280-
defaultPrefix:
281-
description: DefaultPrefix to be appeneded to keys by
282-
all generated parameters. This configuration does not
283-
affect parameter keys explicitly set by users.
284-
type: string
285-
type: object
286-
specToEnvs:
287-
description: SpecToEnvs contains instructions to modify parameters
288-
generation from the instance's spec.
276+
fromSpec:
277+
description: FromSpec contains instructions to generate workload
278+
items from the instance's spec.
289279
items:
290-
description: SpecToEnvsParameterConfiguration contains instructions
291-
to modify parameters generation for the controlled instance
292-
spec.
280+
description: FromSpecConfiguration contains instructions
281+
to generate rendering from the controlled instance spec.
293282
properties:
294283
path:
295284
description: JSON simplified path for the parameter.
296285
type: string
297-
render:
286+
skip:
287+
description: Skip sets whether the object should skip
288+
rendering as a workload item.
289+
type: boolean
290+
toEnv:
298291
description: Render options for the parameter generation.
299292
properties:
300293
defaultValue:
@@ -306,10 +299,6 @@ spec:
306299
description: Name is the name of the parameter to
307300
be created.
308301
type: string
309-
skip:
310-
description: Skip sets whether the object should
311-
skip rendering as a workload parameter.
312-
type: boolean
313302
valueFromBuiltInFunc:
314303
description: ValueFromBuiltInFunc configures the
315304
field to be rendered acording to the chosen built-in
@@ -355,10 +344,58 @@ spec:
355344
- name
356345
type: object
357346
type: object
347+
toVolume:
348+
description: Render options for the parameter generation.
349+
properties:
350+
mountPath:
351+
description: Path where the file will be mounted.
352+
type: string
353+
name:
354+
description: Name for the volume.
355+
type: string
356+
valueFromConfigMap:
357+
description: ValueFromConfigMap is a reference to
358+
a ConfigMap.
359+
properties:
360+
key:
361+
description: The key to select.
362+
type: string
363+
name:
364+
description: Object name
365+
type: string
366+
required:
367+
- key
368+
- name
369+
type: object
370+
valueFromSecret:
371+
description: ValueFromSecret is a reference to a
372+
Secret.
373+
properties:
374+
key:
375+
description: The key to select.
376+
type: string
377+
name:
378+
description: Object name
379+
type: string
380+
required:
381+
- key
382+
- name
383+
type: object
384+
type: object
358385
required:
359386
- path
360387
type: object
361388
type: array
389+
global:
390+
description: Global defines the configuration to be applied
391+
to all generated parameters.
392+
properties:
393+
defaultPrefix:
394+
description: DefaultPrefix to be appeneded to keys by
395+
all generated parameters. This configuration does not
396+
affect parameter keys explicitly set by users.
397+
type: string
398+
type: object
362399
type: object
363400
statusConfiguration:
364401
description: StatusConfiguration contains rules to populate a

docs/reference/registration.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,39 +158,38 @@ The default behavior is to create parameters from each spec element (arrays will
158158

159159
```yaml
160160
parameterConfiguration:
161-
specToEnvs:
161+
fromSpec:
162162
- path: spec.bar
163-
render:
164-
skip: true
163+
skip: true
165164
```
166165

167166
- [x] Change key for generated param. Can be combined.
168167

169168
```yaml
170169
parameterConfiguration:
171-
specToEnvs:
170+
fromSpec:
172171
- path: spec.bar
173-
render:
172+
toEnv:
174173
name: FOO_BAR
175174
```
176175

177176
- [x] Add default value to element when not informed.
178177

179178
```yaml
180179
parameterConfiguration:
181-
specToEnvs:
180+
fromSpec:
182181
- path: spec.bar
183-
render:
182+
toEnv:
184183
defaultValue: hello scoby
185184
```
186185

187186
- [x] Generate secret parameter from element.
188187

189188
```yaml
190189
parameterConfiguration:
191-
specToEnvs:
190+
fromSpec:
192191
- path: spec.credentials
193-
render:
192+
toEnv:
194193
name: FOO_CREDENTIALS
195194
valueFromSecret:
196195
name: spec.credentials.name
@@ -201,9 +200,9 @@ The default behavior is to create parameters from each spec element (arrays will
201200

202201
```yaml
203202
parameterConfiguration:
204-
specToEnvs:
203+
fromSpec:
205204
- path: spec.preferences
206-
render:
205+
toEnv:
207206
valueFromConfigmap:
208207
name: spec.preferences.name
209208
key: spec.preferences.key
@@ -213,23 +212,41 @@ The default behavior is to create parameters from each spec element (arrays will
213212

214213
```yaml
215214
parameterConfiguration:
216-
specToEnvs:
215+
fromSpec:
217216
- path: spec.destination
218-
render:
217+
toEnv:
219218
name: K_SINK
220219
valueFromBuiltInFunc:
221220
name: resolveAddress
222221
```
223222

223+
### Generate Volumes From Spec
224+
225+
Secrets and ConfigMaps can be mounted as a volume inside the workload. The registration needs a name for the volume, the file to mount inside the container and a reference to the Secret or ConfigMap.
226+
227+
- [x] Function: resolve object to internal URL
228+
229+
```yaml
230+
parameterConfiguration:
231+
fromSpec:
232+
- path: spec.userList
233+
toVolume:
234+
name: userfile
235+
mountPath: /opt/user.lst
236+
valueFromConfigMap:
237+
name: spec.userList.name
238+
key: spec.userList.key
239+
```
240+
224241
## Workload Status
225242

226243
- [x] Use parameter value for status.
227244

228245
```yaml
229246
parameterConfiguration:
230-
specToEnvs:
247+
fromSpec:
231248
- path: spec.destination
232-
render:
249+
toEnv:
233250
name: K_SINK
234251
valueFromBuiltInFunc:
235252
name: resolveAddress

docs/samples/01.kuard/03.param.skip/01.kuard-registration.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ spec:
1515
repo: gcr.io/kuar-demo/kuard-amd64:blue
1616

1717
parameterConfiguration:
18-
specToEnvs:
18+
fromSpec:
1919
# Skip variable2 from generating a parameter for the workload
2020
- path: spec.variable2
21-
render:
22-
skip: true
21+
skip: true
2322

docs/samples/01.kuard/04.param.rename/01.kuard-registration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ spec:
1515
repo: gcr.io/kuar-demo/kuard-amd64:blue
1616

1717
parameterConfiguration:
18-
specToEnvs:
18+
fromSpec:
1919
# Use a specific env var key for variable2
2020
- path: spec.variable2
21-
render:
21+
toEnv:
2222
name: KUARD_VARIABLE_TWO
2323

docs/samples/01.kuard/05.param.value/01.kuard-registration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ spec:
1515
repo: gcr.io/kuar-demo/kuard-amd64:blue
1616

1717
parameterConfiguration:
18-
specToEnvs:
18+
fromSpec:
1919
# Set a default value for variable2
2020
- path: spec.variable2
21-
render:
21+
toEnv:
2222
defaultValue: new variable2 value

docs/samples/01.kuard/06.param.secret/01.kuard-registration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ spec:
1616
repo: gcr.io/kuar-demo/kuard-amd64:blue
1717

1818
parameterConfiguration:
19-
specToEnvs:
19+
fromSpec:
2020
# Reference a secret
2121
- path: spec.refToSecret
22-
render:
22+
toEnv:
2323
name: FOO_CREDENTIALS
2424
valueFromSecret:
2525
name: spec.refToSecret.secretName

docs/samples/01.kuard/07.param.configmap/01.kuard-registration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ spec:
1616
repo: gcr.io/kuar-demo/kuard-amd64:blue
1717

1818
parameterConfiguration:
19-
specToEnvs:
19+
fromSpec:
2020
# Reference a ConfigMap
2121
- path: spec.refToConfigMap
22-
render:
22+
toEnv:
2323
valueFromConfigMap:
2424
name: spec.refToConfigMap.configName
2525
key: spec.refToConfigMap.configKey

docs/samples/01.kuard/08.param.addressable/01.kuard-registration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ spec:
1616
repo: gcr.io/kuar-demo/kuard-amd64:blue
1717

1818
parameterConfiguration:
19-
specToEnvs:
19+
fromSpec:
2020
# Resolve an address
2121
- path: spec.refToAddress
22-
render:
22+
toEnv:
2323
name: FOO_SINK
2424
valueFromBuiltInFunc:
2525
name: resolveAddress

docs/samples/02.webhooksource/02.webhooksource-registration.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,36 @@ spec:
2828
- name: K_LOGGING_CONFIG
2929
value: "{}"
3030

31-
specToEnvs:
31+
fromSpec:
3232
- path: spec.eventType
33-
render:
33+
toEnv:
3434
name: WEBHOOK_EVENT_TYPE
3535

3636
- path: spec.eventSource
37-
render:
37+
toEnv:
3838
name: WEBHOOK_EVENT_SOURCE
3939

4040
- path: spec.basicAuthUsername
41-
render:
41+
toEnv:
4242
name: WEBHOOK_BASICAUTH_USERNAME
4343

4444
- path: spec.basicAuthPassword
45-
render:
45+
toEnv:
4646
name: WEBHOOK_BASICAUTH_PASSWORD
4747
valueFromSecret:
4848
name: spec.basicAuthPassword.valueFromSecret.name
4949
key: spec.basicAuthPassword.valueFromSecret.key
5050

5151
- path: spec.eventExtensionAttributes.from
52-
render:
52+
toEnv:
5353
name: WEBHOOK_EVENT_EXTENSION_ATTRIBUTES_FROM
5454

5555
- path: spec.corsAllowOrigin
56-
render:
56+
toEnv:
5757
name: WEBHOOK_CORS_ALLOW_ORIGIN
5858

5959
- path: spec.sink
60-
render:
60+
toEnv:
6161
name: K_SINK
6262
valueFromBuiltInFunc:
6363
name: resolveAddress

0 commit comments

Comments
 (0)