Skip to content

Commit 26e2534

Browse files
committed
add .spec.install.valuesSources and plumb through new conversion logic
Signed-off-by: Joe Lanford <[email protected]>
1 parent 13bb889 commit 26e2534

File tree

7 files changed

+504
-12
lines changed

7 files changed

+504
-12
lines changed

api/v1alpha1/clusterextension_types.go

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

1919
import (
20+
corev1 "k8s.io/api/core/v1"
21+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2022
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2123

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

155256
// CatalogSource defines the required fields for catalog source.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 56 additions & 2 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: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,132 @@ spec:
179179
required:
180180
- name
181181
type: object
182+
valuesSources:
183+
description: |-
184+
valuesSources is a list of sources from which to obtain arbitrary values that
185+
provide configuration for the installation of bundles managed by the
186+
ClusterExtension.
187+
188+
valuesSources is optional. When not specified, the package manager will use
189+
the default configuration of the resolved bundle.
190+
191+
If multiple valuesSources are specified, the values are merged in the order
192+
they are specified. Values from later sources will override values from earlier
193+
sources.
194+
195+
Bundles can optionally provide a schema for these values. When bundles provide
196+
a schema, it is used to validate these values before proceeding with the
197+
installation. Validation errors are reported via the ClusterExtension status.
198+
items:
199+
description: |-
200+
ValuesSource is a discriminated union of possible sources for values.
201+
ValuesSource contains the sourcing information for those values.
202+
properties:
203+
configMap:
204+
description: |-
205+
configMap is a reference to a key in a specific ConfigMap in the installNamespace.
206+
The referenced ConfigMap is expected to contain the specified key, whose value
207+
contains the desired configuration.
208+
209+
ConfigMaps are useful for storing larger, more complex configurations that do
210+
not include sensitive information.
211+
212+
The service account provided in the spec.install field must have 'get' permission in
213+
order to read the referenced ConfigMap.
214+
properties:
215+
key:
216+
description: |-
217+
key is a reference to a key in the data field of
218+
the referenced object.
219+
type: string
220+
name:
221+
default: ""
222+
description: |-
223+
Name of the referent.
224+
This field is effectively required, but due to backwards compatibility is
225+
allowed to be empty. Instances of this type with an empty value here are
226+
almost certainly wrong.
227+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
228+
type: string
229+
required:
230+
- key
231+
type: object
232+
x-kubernetes-map-type: atomic
233+
inline:
234+
description: |-
235+
inline is a map of arbitrary key-value pairs.
236+
237+
Inlined values are useful for small, simple configurations that do not
238+
include sensitive information.
239+
type: object
240+
x-kubernetes-preserve-unknown-fields: true
241+
secret:
242+
description: |-
243+
secret is a reference to a key in a specific Secret in the installNamespace.
244+
The referenced Secret is expected to contain the specified key, whose value
245+
contains the desired configuration.
246+
247+
Secrets are useful for storing larger, more complex configurations or
248+
configurations that include sensitive information.
249+
250+
The service account provided in the spec.install field must have 'get' permission in
251+
order to read the referenced Secret.
252+
properties:
253+
key:
254+
description: |-
255+
key is a reference to a key in the data field of
256+
the referenced object.
257+
type: string
258+
name:
259+
default: ""
260+
description: |-
261+
Name of the referent.
262+
This field is effectively required, but due to backwards compatibility is
263+
allowed to be empty. Instances of this type with an empty value here are
264+
almost certainly wrong.
265+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
266+
type: string
267+
required:
268+
- key
269+
type: object
270+
x-kubernetes-map-type: atomic
271+
type:
272+
description: |-
273+
type is a reference to the type of source the values are sourced from.
274+
type is required.
275+
276+
The allowed values are "Inline", "ConfigMap", and "Secret".
277+
278+
When set to "Inline", the values are sourced directly from the inlined content.
279+
When using an inline source, the inline field must be set and must be the only field defined for this type.
280+
281+
When set to "ConfigMap", the values are sourced from the specified ConfigMap in the installNamespace.
282+
When using a ConfigMap source, the configMap field must be set and must be the only field defined for this type.
283+
284+
When set to "Secret", the values are sourced from the specified Secret in the installNamespace.
285+
When using a Secret source, the secret field must be set and must be the only field defined for this type.
286+
enum:
287+
- Inline
288+
- ConfigMap
289+
- Secret
290+
type: string
291+
required:
292+
- type
293+
type: object
294+
x-kubernetes-validations:
295+
- message: inline is required when type is Inline, and forbidden
296+
otherwise
297+
rule: 'has(self.type) && self.type == ''Inline'' ?has(self.inline)
298+
: !has(self.inline)'
299+
- message: configMap is required when type is ConfigMap, and
300+
forbidden otherwise
301+
rule: 'has(self.type) && self.type == ''ConfigMap'' ?has(self.configMap)
302+
: !has(self.configMap)'
303+
- message: secret is required when type is Secret, and forbidden
304+
otherwise
305+
rule: 'has(self.type) && self.type == ''Secret'' ?has(self.secret)
306+
: !has(self.secret)'
307+
type: array
182308
required:
183309
- namespace
184310
- serviceAccount

0 commit comments

Comments
 (0)