Skip to content

Commit 5f255ee

Browse files
committed
add .spec.template.valuesSources and plumb through new conversion logic
Signed-off-by: Joe Lanford <[email protected]>
1 parent 6025378 commit 5f255ee

File tree

7 files changed

+560
-11
lines changed

7 files changed

+560
-11
lines changed

api/v1/clusterextension_types.go

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1
1818

1919
import (
20+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

@@ -87,6 +88,15 @@ type ClusterExtensionSpec struct {
8788
// +kubebuilder:validation:Required
8889
Source SourceConfig `json:"source"`
8990

91+
// config stores any custom configuration to be used when templating
92+
// content for this extension.
93+
//
94+
// config is optional. When not specified, the package manager will use
95+
// the default configuration of the extension.
96+
//
97+
//+optional
98+
Template *ClusterExtensionTemplate `json:"template,omitempty"`
99+
90100
// install is an optional field used to configure the installation options
91101
// for the ClusterExtension such as the pre-flight check configuration.
92102
//
@@ -138,6 +148,113 @@ type ClusterExtensionInstallConfig struct {
138148
Preflight *PreflightConfig `json:"preflight,omitempty"`
139149
}
140150

151+
type ValuesSourceType string
152+
153+
const (
154+
ValuesSourceTypeInline ValuesSourceType = "Inline"
155+
ValuesSourceTypeConfigMap ValuesSourceType = "ConfigMap"
156+
ValuesSourceTypeSecret ValuesSourceType = "Secret"
157+
)
158+
159+
type ClusterExtensionTemplate struct {
160+
// valuesSources is a list of sources from which to obtain arbitrary values that
161+
// provide configuration for the installation of bundles managed by the
162+
// ClusterExtension.
163+
//
164+
// valuesSources is optional. When not specified, the package manager will use
165+
// the default configuration of the resolved bundle.
166+
//
167+
// If multiple valuesSources are specified, the values are merged in the order
168+
// they are specified. Values from later sources will override values from earlier
169+
// sources.
170+
//
171+
// Bundles can optionally provide a schema for these values. When bundles provide
172+
// a schema, it is used to validate these values before proceeding with the
173+
// installation. Validation errors are reported via the ClusterExtension status.
174+
//
175+
//+optional
176+
ValuesSources []ValuesSource `json:"valuesSources,omitempty"`
177+
}
178+
179+
// ValuesSource is a discriminated union of possible sources for values.
180+
// ValuesSource contains the sourcing information for those values.
181+
// +union
182+
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'Inline' ?has(self.inline) : !has(self.inline)",message="inline is required when type is Inline, and forbidden otherwise"
183+
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'ConfigMap' ?has(self.configMap) : !has(self.configMap)",message="configMap is required when type is ConfigMap, and forbidden otherwise"
184+
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'Secret' ?has(self.secret) : !has(self.secret)",message="secret is required when type is Secret, and forbidden otherwise"
185+
type ValuesSource struct {
186+
// type is a reference to the type of source the values are sourced from.
187+
// type is required.
188+
//
189+
// The allowed values are "Inline", "ConfigMap", and "Secret".
190+
//
191+
// When set to "Inline", the values are sourced directly from the inlined content.
192+
// When using an inline source, the inline field must be set and must be the only field defined for this type.
193+
//
194+
// When set to "ConfigMap", the values are sourced from the specified ConfigMap in the installNamespace.
195+
// When using a ConfigMap source, the configMap field must be set and must be the only field defined for this type.
196+
//
197+
// When set to "Secret", the values are sourced from the specified Secret in the installNamespace.
198+
// When using a Secret source, the secret field must be set and must be the only field defined for this type.
199+
//
200+
// +unionDiscriminator
201+
// +kubebuilder:validation:Enum:="Inline";"ConfigMap";"Secret"
202+
// +kubebuilder:validation:Required
203+
Type ValuesSourceType `json:"type"`
204+
205+
// inline is a map of arbitrary key-value pairs.
206+
//
207+
// Inlined values are useful for small, simple configurations that do not
208+
// include sensitive information.
209+
//
210+
//+kubebuilder:pruning:PreserveUnknownFields
211+
//+kubebuilder:validation:Type=object
212+
//+kubebuilder:validation:Schemaless
213+
//+optional
214+
Inline *apiextensionsv1.JSON `json:"inline,omitempty"`
215+
216+
// configMap is a reference to a key in a specific ConfigMap in the installNamespace.
217+
// The referenced ConfigMap is expected to contain the specified key, whose value
218+
// contains the desired configuration.
219+
//
220+
// ConfigMaps are useful for storing larger, more complex configurations that do
221+
// not include sensitive information.
222+
//
223+
// The service account provided in the spec.install field must have 'get' permission in
224+
// order to read the referenced ConfigMap.
225+
//
226+
//+optional
227+
ConfigMap *LocalObjectReferenceWithKey `json:"configMap,omitempty"`
228+
229+
// secret is a reference to a key in a specific Secret in the installNamespace.
230+
// The referenced Secret is expected to contain the specified key, whose value
231+
// contains the desired configuration.
232+
//
233+
// Secrets are useful for storing larger, more complex configurations or
234+
// configurations that include sensitive information.
235+
//
236+
// The service account provided in the spec.install field must have 'get' permission in
237+
// order to read the referenced Secret.
238+
//
239+
//+optional
240+
Secret *LocalObjectReferenceWithKey `json:"secret,omitempty"`
241+
}
242+
243+
type LocalObjectReferenceWithKey struct {
244+
// name is the name of a resource in the same namespace as the ClusterExtension.
245+
// name is required.
246+
//
247+
//+kubebuilder:validation:Required
248+
Name string `json:"name"`
249+
250+
// key is a reference to a key in the data field of
251+
// the referenced object.
252+
// key is required.
253+
//
254+
//+kubebuilder:validation:Required
255+
Key string `json:"key"`
256+
}
257+
141258
// CatalogSource defines the attributes used to identify and filter content from a catalog.
142259
type CatalogSource struct {
143260
// packageName is a reference to the name of the package to be installed

api/v1/zz_generated.deepcopy.go

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

cmd/manager/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ func main() {
285285
}
286286

287287
applier := &applier.Helm{
288+
ActionConfigGetter: cfgGetter,
288289
ActionClientGetter: acg,
289290
Preflights: preflights,
290291
}

config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,135 @@ spec:
456456
otherwise
457457
rule: 'has(self.sourceType) && self.sourceType == ''Catalog'' ?
458458
has(self.catalog) : !has(self.catalog)'
459+
template:
460+
description: |-
461+
config stores any custom configuration to be used when templating
462+
content for this extension.
463+
464+
config is optional. When not specified, the package manager will use
465+
the default configuration of the extension.
466+
properties:
467+
valuesSources:
468+
description: |-
469+
valuesSources is a list of sources from which to obtain arbitrary values that
470+
provide configuration for the installation of bundles managed by the
471+
ClusterExtension.
472+
473+
valuesSources is optional. When not specified, the package manager will use
474+
the default configuration of the resolved bundle.
475+
476+
If multiple valuesSources are specified, the values are merged in the order
477+
they are specified. Values from later sources will override values from earlier
478+
sources.
479+
480+
Bundles can optionally provide a schema for these values. When bundles provide
481+
a schema, it is used to validate these values before proceeding with the
482+
installation. Validation errors are reported via the ClusterExtension status.
483+
items:
484+
description: |-
485+
ValuesSource is a discriminated union of possible sources for values.
486+
ValuesSource contains the sourcing information for those values.
487+
properties:
488+
configMap:
489+
description: |-
490+
configMap is a reference to a key in a specific ConfigMap in the installNamespace.
491+
The referenced ConfigMap is expected to contain the specified key, whose value
492+
contains the desired configuration.
493+
494+
ConfigMaps are useful for storing larger, more complex configurations that do
495+
not include sensitive information.
496+
497+
The service account provided in the spec.install field must have 'get' permission in
498+
order to read the referenced ConfigMap.
499+
properties:
500+
key:
501+
description: |-
502+
key is a reference to a key in the data field of
503+
the referenced object.
504+
key is required.
505+
type: string
506+
name:
507+
description: |-
508+
name is the name of a resource in the same namespace as the ClusterExtension.
509+
name is required.
510+
type: string
511+
required:
512+
- key
513+
- name
514+
type: object
515+
inline:
516+
description: |-
517+
inline is a map of arbitrary key-value pairs.
518+
519+
Inlined values are useful for small, simple configurations that do not
520+
include sensitive information.
521+
type: object
522+
x-kubernetes-preserve-unknown-fields: true
523+
secret:
524+
description: |-
525+
secret is a reference to a key in a specific Secret in the installNamespace.
526+
The referenced Secret is expected to contain the specified key, whose value
527+
contains the desired configuration.
528+
529+
Secrets are useful for storing larger, more complex configurations or
530+
configurations that include sensitive information.
531+
532+
The service account provided in the spec.install field must have 'get' permission in
533+
order to read the referenced Secret.
534+
properties:
535+
key:
536+
description: |-
537+
key is a reference to a key in the data field of
538+
the referenced object.
539+
key is required.
540+
type: string
541+
name:
542+
description: |-
543+
name is the name of a resource in the same namespace as the ClusterExtension.
544+
name is required.
545+
type: string
546+
required:
547+
- key
548+
- name
549+
type: object
550+
type:
551+
description: |-
552+
type is a reference to the type of source the values are sourced from.
553+
type is required.
554+
555+
The allowed values are "Inline", "ConfigMap", and "Secret".
556+
557+
When set to "Inline", the values are sourced directly from the inlined content.
558+
When using an inline source, the inline field must be set and must be the only field defined for this type.
559+
560+
When set to "ConfigMap", the values are sourced from the specified ConfigMap in the installNamespace.
561+
When using a ConfigMap source, the configMap field must be set and must be the only field defined for this type.
562+
563+
When set to "Secret", the values are sourced from the specified Secret in the installNamespace.
564+
When using a Secret source, the secret field must be set and must be the only field defined for this type.
565+
enum:
566+
- Inline
567+
- ConfigMap
568+
- Secret
569+
type: string
570+
required:
571+
- type
572+
type: object
573+
x-kubernetes-validations:
574+
- message: inline is required when type is Inline, and forbidden
575+
otherwise
576+
rule: 'has(self.type) && self.type == ''Inline'' ?has(self.inline)
577+
: !has(self.inline)'
578+
- message: configMap is required when type is ConfigMap, and
579+
forbidden otherwise
580+
rule: 'has(self.type) && self.type == ''ConfigMap'' ?has(self.configMap)
581+
: !has(self.configMap)'
582+
- message: secret is required when type is Secret, and forbidden
583+
otherwise
584+
rule: 'has(self.type) && self.type == ''Secret'' ?has(self.secret)
585+
: !has(self.secret)'
586+
type: array
587+
type: object
459588
required:
460589
- namespace
461590
- serviceAccount

0 commit comments

Comments
 (0)