Skip to content

Commit dfc07b0

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

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

0 commit comments

Comments
 (0)