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

Commit

Permalink
Merge pull request #138 from triggermesh/task/add-spec-to-volumes
Browse files Browse the repository at this point in the history
Render: add spec to volumes to API
  • Loading branch information
Pablo Mercado committed May 19, 2023
2 parents 079f008 + 991e884 commit a47043e
Show file tree
Hide file tree
Showing 19 changed files with 767 additions and 439 deletions.
83 changes: 60 additions & 23 deletions config/300-crdregistration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ spec:
transformed into workload parameters.
properties:
addEnvs:
description: AddEnvs contains configurations for parameters
to be added to the workload not derived from the user instance.
description: AddEnvs contains instructions to create environment
variables at the workload not derived from the user instance.
items:
description: EnvVar represents an environment variable present
in a Container.
Expand Down Expand Up @@ -273,28 +273,21 @@ spec:
- name
type: object
type: array
global:
description: Global defines the configuration to be applied
to all generated parameters.
properties:
defaultPrefix:
description: DefaultPrefix to be appeneded to keys by
all generated parameters. This configuration does not
affect parameter keys explicitly set by users.
type: string
type: object
specToEnvs:
description: SpecToEnvs contains instructions to modify parameters
generation from the instance's spec.
fromSpec:
description: FromSpec contains instructions to generate workload
items from the instance's spec.
items:
description: SpecToEnvsParameterConfiguration contains instructions
to modify parameters generation for the controlled instance
spec.
description: FromSpecConfiguration contains instructions
to generate rendering from the controlled instance spec.
properties:
path:
description: JSON simplified path for the parameter.
type: string
render:
skip:
description: Skip sets whether the object should skip
rendering as a workload item.
type: boolean
toEnv:
description: Render options for the parameter generation.
properties:
defaultValue:
Expand All @@ -306,10 +299,6 @@ spec:
description: Name is the name of the parameter to
be created.
type: string
skip:
description: Skip sets whether the object should
skip rendering as a workload parameter.
type: boolean
valueFromBuiltInFunc:
description: ValueFromBuiltInFunc configures the
field to be rendered acording to the chosen built-in
Expand Down Expand Up @@ -355,10 +344,58 @@ spec:
- name
type: object
type: object
toVolume:
description: Render options for the parameter generation.
properties:
mountPath:
description: Path where the file will be mounted.
type: string
name:
description: Name for the volume.
type: string
valueFromConfigMap:
description: ValueFromConfigMap is a reference to
a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: Object name
type: string
required:
- key
- name
type: object
valueFromSecret:
description: ValueFromSecret is a reference to a
Secret.
properties:
key:
description: The key to select.
type: string
name:
description: Object name
type: string
required:
- key
- name
type: object
type: object
required:
- path
type: object
type: array
global:
description: Global defines the configuration to be applied
to all generated parameters.
properties:
defaultPrefix:
description: DefaultPrefix to be appeneded to keys by
all generated parameters. This configuration does not
affect parameter keys explicitly set by users.
type: string
type: object
type: object
statusConfiguration:
description: StatusConfiguration contains rules to populate a
Expand Down
47 changes: 32 additions & 15 deletions docs/reference/registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,39 +158,38 @@ The default behavior is to create parameters from each spec element (arrays will

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.bar
render:
skip: true
skip: true
```

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

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.bar
render:
toEnv:
name: FOO_BAR
```

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

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.bar
render:
toEnv:
defaultValue: hello scoby
```

- [x] Generate secret parameter from element.

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.credentials
render:
toEnv:
name: FOO_CREDENTIALS
valueFromSecret:
name: spec.credentials.name
Expand All @@ -201,9 +200,9 @@ The default behavior is to create parameters from each spec element (arrays will

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.preferences
render:
toEnv:
valueFromConfigmap:
name: spec.preferences.name
key: spec.preferences.key
Expand All @@ -213,23 +212,41 @@ The default behavior is to create parameters from each spec element (arrays will

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.destination
render:
toEnv:
name: K_SINK
valueFromBuiltInFunc:
name: resolveAddress
```

### Generate Volumes From Spec

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.

- [x] Function: resolve object to internal URL

```yaml
parameterConfiguration:
fromSpec:
- path: spec.userList
toVolume:
name: userfile
mountPath: /opt/user.lst
valueFromConfigMap:
name: spec.userList.name
key: spec.userList.key
```

## Workload Status

- [x] Use parameter value for status.

```yaml
parameterConfiguration:
specToEnvs:
fromSpec:
- path: spec.destination
render:
toEnv:
name: K_SINK
valueFromBuiltInFunc:
name: resolveAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ spec:
repo: gcr.io/kuar-demo/kuard-amd64:blue

parameterConfiguration:
specToEnvs:
fromSpec:
# Skip variable2 from generating a parameter for the workload
- path: spec.variable2
render:
skip: true
skip: true

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ spec:
repo: gcr.io/kuar-demo/kuard-amd64:blue

parameterConfiguration:
specToEnvs:
fromSpec:
# Use a specific env var key for variable2
- path: spec.variable2
render:
toEnv:
name: KUARD_VARIABLE_TWO

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ spec:
repo: gcr.io/kuar-demo/kuard-amd64:blue

parameterConfiguration:
specToEnvs:
fromSpec:
# Set a default value for variable2
- path: spec.variable2
render:
toEnv:
defaultValue: new variable2 value
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ spec:
repo: gcr.io/kuar-demo/kuard-amd64:blue

parameterConfiguration:
specToEnvs:
fromSpec:
# Reference a secret
- path: spec.refToSecret
render:
toEnv:
name: FOO_CREDENTIALS
valueFromSecret:
name: spec.refToSecret.secretName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ spec:
repo: gcr.io/kuar-demo/kuard-amd64:blue

parameterConfiguration:
specToEnvs:
fromSpec:
# Reference a ConfigMap
- path: spec.refToConfigMap
render:
toEnv:
valueFromConfigMap:
name: spec.refToConfigMap.configName
key: spec.refToConfigMap.configKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ spec:
repo: gcr.io/kuar-demo/kuard-amd64:blue

parameterConfiguration:
specToEnvs:
fromSpec:
# Resolve an address
- path: spec.refToAddress
render:
toEnv:
name: FOO_SINK
valueFromBuiltInFunc:
name: resolveAddress
Expand Down
16 changes: 8 additions & 8 deletions docs/samples/02.webhooksource/02.webhooksource-registration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@ spec:
- name: K_LOGGING_CONFIG
value: "{}"

specToEnvs:
fromSpec:
- path: spec.eventType
render:
toEnv:
name: WEBHOOK_EVENT_TYPE

- path: spec.eventSource
render:
toEnv:
name: WEBHOOK_EVENT_SOURCE

- path: spec.basicAuthUsername
render:
toEnv:
name: WEBHOOK_BASICAUTH_USERNAME

- path: spec.basicAuthPassword
render:
toEnv:
name: WEBHOOK_BASICAUTH_PASSWORD
valueFromSecret:
name: spec.basicAuthPassword.valueFromSecret.name
key: spec.basicAuthPassword.valueFromSecret.key

- path: spec.eventExtensionAttributes.from
render:
toEnv:
name: WEBHOOK_EVENT_EXTENSION_ATTRIBUTES_FROM

- path: spec.corsAllowOrigin
render:
toEnv:
name: WEBHOOK_CORS_ALLOW_ORIGIN

- path: spec.sink
render:
toEnv:
name: K_SINK
valueFromBuiltInFunc:
name: resolveAddress
Expand Down
Loading

0 comments on commit a47043e

Please sign in to comment.