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

Commit 1ef0584

Browse files
author
odacremolbap
committed
use fromSpec as a rendering base
1 parent 8cb2038 commit 1ef0584

File tree

7 files changed

+585
-379
lines changed

7 files changed

+585
-379
lines changed

config/300-crdregistration.yaml

Lines changed: 53 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -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 generate
288-
environment variables 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 generate environment variables from the controlled
292-
instance 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,58 +344,58 @@ spec:
355344
- name
356345
type: object
357346
type: object
358-
required:
359-
- path
360-
type: object
361-
type: array
362-
specToVolumes:
363-
description: SpecToVolumes contains instructions to generate
364-
volumes and mounts from the instance's spec.
365-
items:
366-
description: SpecToVolumeParameterConfiguration contains
367-
instructions to generate volumes and volume mounts from
368-
the controlled instance spec.
369-
properties:
370-
mountPath:
371-
description: Path where the file will be mounted.
372-
type: string
373-
name:
374-
description: Name for the volume.
375-
type: string
376-
path:
377-
description: JSON simplified path for the parameter.
378-
type: string
379-
valueFromConfigMap:
380-
description: ValueFromConfigMap is a reference to a
381-
ConfigMap.
382-
properties:
383-
key:
384-
description: The key to select.
385-
type: string
386-
name:
387-
description: Object name
388-
type: string
389-
required:
390-
- key
391-
- name
392-
type: object
393-
valueFromSecret:
394-
description: ValueFromSecret is a reference to a Secret.
347+
toVolume:
348+
description: Render options for the parameter generation.
395349
properties:
396-
key:
397-
description: The key to select.
350+
mountPath:
351+
description: Path where the file will be mounted.
398352
type: string
399353
name:
400-
description: Object name
354+
description: Name for the volume.
401355
type: string
402-
required:
403-
- key
404-
- name
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
405384
type: object
406385
required:
407386
- path
408387
type: object
409388
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
410399
type: object
411400
statusConfiguration:
412401
description: StatusConfiguration contains rules to populate a

docs/reference/registration.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ 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.
@@ -231,11 +230,12 @@ Secrets and ConfigMaps can be mounted as a volume inside the workload. The regis
231230
parameterConfiguration:
232231
specToVolumes:
233232
- path: spec.userList
234-
name: userfile
235-
mountPath: /opt/user.lst
236-
valueFromConfigMap:
237-
name: spec.userList.name
238-
key: spec.userList.key
233+
render:
234+
name: userfile
235+
mountPath: /opt/user.lst
236+
valueFromConfigMap:
237+
name: spec.userList.name
238+
key: spec.userList.key
239239
```
240240

241241
## Workload Status

docs/tutorial.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,14 @@ spec:
316316
fromImage:
317317
repo: gcr.io/kuar-demo/kuard-amd64:blue
318318
parameterConfiguration:
319-
specToEnvs:
319+
fromSpec:
320320
# Skip variable2 from generating a parameter for the workload
321321
- path: spec.variable2
322-
render:
323-
skip: true
322+
skip: true
324323

325324
```
326325

327-
The `spec.workload.parameterConfiguration.specToEnvs[].render.skip` boolean indicates whether the environment variable for the element should be generated.
326+
The `spec.workload.parameterConfiguration.fromSpec[].skip` boolean indicates whether the environment variable for the element should be generated.
328327

329328
Create the registration:
330329

@@ -377,7 +376,7 @@ kubectl delete crdregistration kuard
377376

378377
### Parameter Renaming
379378

380-
Most often expected environment variables at the container do not match Scoby's automatic rendering. All generated environment variables can be renamed using `spec.workload.parameterConfiguration.specToEnvs[].render.key`.
379+
Most often expected environment variables at the container do not match Scoby's automatic rendering. All generated environment variables can be renamed using `spec.workload.parameterConfiguration.fromSpec[].toEnv.name`.
381380

382381
```yaml
383382
apiVersion: scoby.triggermesh.io/v1alpha1
@@ -396,10 +395,10 @@ spec:
396395
fromImage:
397396
repo: gcr.io/kuar-demo/kuard-amd64:blue
398397
parameterConfiguration:
399-
specToEnvs:
398+
fromSpec:
400399
# Rename variable2
401400
- path: spec.variable2
402-
render:
401+
toEnv:
403402
name: KUARD_VARIABLE_TWO
404403
```
405404
@@ -458,7 +457,7 @@ kubectl delete crdregistration kuard
458457

459458
### Parameter Default Value
460459

461-
The value for an environment variable can be set to a default value using `spec.workload.parameterConfiguration.specToEnvs[].render.defaultValue`.
460+
The value for an environment variable can be set to a default value using `spec.workload.parameterConfiguration.fromSpec[].toEnv.defaultValue`.
462461

463462
```yaml
464463
apiVersion: scoby.triggermesh.io/v1alpha1
@@ -477,10 +476,10 @@ spec:
477476
fromImage:
478477
repo: gcr.io/kuar-demo/kuard-amd64:blue
479478
parameterConfiguration:
480-
specToEnvs:
479+
fromSpec:
481480
# Override variable2 value
482481
- path: spec.variable2
483-
render:
482+
toEnv:
484483
defaultValue: new variable2 value
485484
```
486485
@@ -539,7 +538,7 @@ kubectl delete crdregistration kuard
539538

540539
### Parameter Value From Secret
541540

542-
The value for an environment variable can reference a Secret through the `spec.workload.parameterConfiguration.specToEnvs[].render.valueFromSecret` customization option, that needs the `name` and `key` subelements to be set. In this example we will also be setting the variable name.
541+
The value for an environment variable can reference a Secret through the `spec.workload.parameterConfiguration.fromSpec[].toEnv.valueFromSecret` customization option, that needs the `name` and `key` subelements to be set. In this example we will also be setting the variable name.
543542

544543
```yaml
545544
apiVersion: scoby.triggermesh.io/v1alpha1
@@ -558,10 +557,10 @@ spec:
558557
fromImage:
559558
repo: gcr.io/kuar-demo/kuard-amd64:blue
560559
parameterConfiguration:
561-
specToEnvs:
560+
fromSpec:
562561
# Reference a secret
563562
- path: spec.refToSecret
564-
render:
563+
toEnv:
565564
name: FOO_CREDENTIALS
566565
valueFromSecret:
567566
name: spec.refToSecret.secretName
@@ -634,7 +633,7 @@ kubectl delete secret kuard-secret
634633

635634
### Parameter Value From ConfigMap
636635

637-
The value for an environment variable can reference a ConfigMap through the `spec.workload.parameterConfiguration.specToEnvs[].render.valueFromConfigMap` customization option, that needs the `name` and `key` subelements to be set.
636+
The value for an environment variable can reference a ConfigMap through the `spec.workload.parameterConfiguration.fromSpec[].toEnv.valueFromConfigMap` customization option, that needs the `name` and `key` subelements to be set.
638637

639638
```yaml
640639
apiVersion: scoby.triggermesh.io/v1alpha1
@@ -653,10 +652,10 @@ spec:
653652
fromImage:
654653
repo: gcr.io/kuar-demo/kuard-amd64:blue
655654
parameterConfiguration:
656-
specToEnvs:
655+
fromSpec:
657656
# Reference a ConfigMap
658657
- path: spec.refToConfigMap
659-
render:
658+
toEnv:
660659
valueFromConfigMap:
661660
name: spec.refToConfigMap.configName
662661
key: spec.refToConfigMap.configKey
@@ -742,7 +741,7 @@ A destination duck type informs either an URI, a Kubernetes service, or a Kubern
742741
uri: <uri>
743742
```
744743
745-
Use the built-in function `spec.workload.parameterConfiguration.specToEnvs[].valueFromBuiltInFunc.resolveAddress` on the element that contains the Destination type. As an added feature this example also updates an status element with the resolved address.
744+
Use the built-in function `spec.workload.parameterConfiguration.fromSpec[].toEnv.valueFromBuiltInFunc.resolveAddress` on the element that contains the Destination type. As an added feature this example also updates an status element with the resolved address.
746745

747746
```yaml
748747
apiVersion: scoby.triggermesh.io/v1alpha1
@@ -761,10 +760,10 @@ spec:
761760
fromImage:
762761
repo: gcr.io/kuar-demo/kuard-amd64:blue
763762
parameterConfiguration:
764-
specToEnvs:
763+
fromSpec:
765764
# Resolve an address
766765
- path: spec.refToAddress
767-
render:
766+
toEnv:
768767
name: FOO_SINK
769768
valueFromBuiltInFunc:
770769
name: resolveAddress

0 commit comments

Comments
 (0)