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

Commit 8cb2038

Browse files
author
odacremolbap
committed
add spec to volumes to API
1 parent 079f008 commit 8cb2038

File tree

4 files changed

+132
-9
lines changed

4 files changed

+132
-9
lines changed

config/300-crdregistration.yaml

Lines changed: 54 additions & 6 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.
@@ -284,12 +284,12 @@ spec:
284284
type: string
285285
type: object
286286
specToEnvs:
287-
description: SpecToEnvs contains instructions to modify parameters
288-
generation from the instance's spec.
287+
description: SpecToEnvs contains instructions to generate
288+
environment variables from the instance's spec.
289289
items:
290290
description: SpecToEnvsParameterConfiguration contains instructions
291-
to modify parameters generation for the controlled instance
292-
spec.
291+
to generate environment variables from the controlled
292+
instance spec.
293293
properties:
294294
path:
295295
description: JSON simplified path for the parameter.
@@ -359,6 +359,54 @@ spec:
359359
- path
360360
type: object
361361
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.
395+
properties:
396+
key:
397+
description: The key to select.
398+
type: string
399+
name:
400+
description: Object name
401+
type: string
402+
required:
403+
- key
404+
- name
405+
type: object
406+
required:
407+
- path
408+
type: object
409+
type: array
362410
type: object
363411
statusConfiguration:
364412
description: StatusConfiguration contains rules to populate a

docs/reference/registration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ The default behavior is to create parameters from each spec element (arrays will
221221
name: resolveAddress
222222
```
223223

224+
### Generate Volumes From Spec
225+
226+
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.
227+
228+
- [x] Function: resolve object to internal URL
229+
230+
```yaml
231+
parameterConfiguration:
232+
specToVolumes:
233+
- path: spec.userList
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.

pkg/apis/common/v1alpha1/workload_types.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@ type ParameterConfiguration struct {
3737
// +optional
3838
Global *GlobalParameterConfiguration `json:"global,omitempty"`
3939

40-
// AddEnvs contains configurations for parameters to be added to the workload
40+
// AddEnvs contains instructions to create environment variables at the workload
4141
// not derived from the user instance.
4242
// +optional
4343
AddEnvs []corev1.EnvVar `json:"addEnvs,omitempty"`
4444

45-
// SpecToEnvs contains instructions to modify parameters generation from
45+
// SpecToEnvs contains instructions to generate environment variables from
4646
// the instance's spec.
4747
// +optional
4848
SpecToEnvs []SpecToEnvParameterConfiguration `json:"specToEnvs,omitempty"`
49+
50+
// SpecToVolumes contains instructions to generate volumes and mounts from
51+
// the instance's spec.
52+
// +optional
53+
SpecToVolumes []SpecToVolumeParameterConfiguration `json:"specToVolumes,omitempty"`
4954
}
5055

5156
// GlobalParameterConfiguration defines configuration to be applied to all generated parameters.
@@ -63,7 +68,7 @@ func (gpc *GlobalParameterConfiguration) GetDefaultPrefix() string {
6368
return *gpc.DefaultPrefix
6469
}
6570

66-
// SpecToEnvsParameterConfiguration contains instructions to modify parameters generation for
71+
// SpecToEnvsParameterConfiguration contains instructions to generate environment variables from
6772
// the controlled instance spec.
6873
type SpecToEnvParameterConfiguration struct {
6974
// JSON simplified path for the parameter.
@@ -74,6 +79,27 @@ type SpecToEnvParameterConfiguration struct {
7479
Render *ParameterRenderConfiguration `json:"render,omitempty"`
7580
}
7681

82+
// SpecToVolumeParameterConfiguration contains instructions to generate volumes
83+
// and volume mounts from the controlled instance spec.
84+
type SpecToVolumeParameterConfiguration struct {
85+
// JSON simplified path for the parameter.
86+
Path string `json:"path"`
87+
88+
// Name for the volume.
89+
Name string `json:"name,omitempty"`
90+
91+
// Path where the file will be mounted.
92+
MountPath string `json:"mountPath,omitempty"`
93+
94+
// ValueFromConfigMap is a reference to a ConfigMap.
95+
// +optional
96+
ValueFromConfigMap *ObjectReference `json:"valueFromConfigMap,omitempty"`
97+
98+
// ValueFromSecret is a reference to a Secret.
99+
// +optional
100+
ValueFromSecret *ObjectReference `json:"valueFromSecret,omitempty"`
101+
}
102+
77103
// ParameterRenderConfiguration are the customization options for an specific
78104
// parameter generation.
79105
type ParameterRenderConfiguration struct {

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

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)