Skip to content

Commit da89a12

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

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

Diff for: api/v1alpha1/clusterextension_types.go

+22
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

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

2223
"github.com/operator-framework/operator-controller/internal/conditionsets"
@@ -150,6 +151,27 @@ type ClusterExtensionInstallConfig struct {
150151
//
151152
//+optional
152153
Preflight *PreflightConfig `json:"preflight,omitempty"`
154+
155+
// values is a map of key-value pairs that provide configuration for the
156+
// installation of the package specified in the packageName field.
157+
//
158+
// It is an optional field.
159+
//
160+
// When specified, it is passed to the package manager to be used during the
161+
// installation process. The package manager is responsible for interpreting
162+
// the values provided in this field. The bundle that is resolved for the
163+
// cluster extension may optionally provide a schema for these values. In that
164+
// case, the package manager will validate the values against the schema before
165+
// proceeding with the installation.
166+
//
167+
// When not specified, the package manager will use the default configuration
168+
// of the resolved bundle.
169+
//
170+
//+optional
171+
//+kubebuilder:pruning:PreserveUnknownFields
172+
//+kubebuilder:validation:Type=object
173+
//+kubebuilder:validation:Schemaless
174+
Values apiextensionsv1.JSON `json:"values,omitempty"`
153175
}
154176

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

Diff for: api/v1alpha1/zz_generated.deepcopy.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ spec:
179179
required:
180180
- name
181181
type: object
182+
values:
183+
description: |-
184+
values is a map of key-value pairs that provide configuration for the
185+
installation of the package specified in the packageName field.
186+
187+
It is an optional field.
188+
189+
When specified, it is passed to the package manager to be used during the
190+
installation process. The package manager is responsible for interpreting
191+
the values provided in this field. The bundle that is resolved for the
192+
cluster extension may optionally provide a schema for these values. In that
193+
case, the package manager will validate the values against the schema before
194+
proceeding with the installation.
195+
196+
When not specified, the package manager will use the default configuration
197+
of the resolved bundle.
198+
type: object
199+
x-kubernetes-preserve-unknown-fields: true
182200
required:
183201
- namespace
184202
- serviceAccount

Diff for: docs/api-reference/operator-controller-api-reference.md

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ _Appears in:_
123123
| `namespace` _string_ | namespace is a reference to the Namespace in which the bundle of<br />content for the package referenced in the packageName field will be applied.<br />The bundle may contain cluster-scoped resources or resources that are<br />applied to other Namespaces. This Namespace is expected to exist.<br /><br />namespace is required, immutable, and follows the DNS label standard<br />as defined in [RFC 1123]. This means that valid values:<br /> - Contain no more than 63 characters<br /> - Contain only lowercase alphanumeric characters or '-'<br /> - Start with an alphanumeric character<br /> - End with an alphanumeric character<br /><br />Some examples of valid values are:<br /> - some-namespace<br /> - 123-namespace<br /> - 1-namespace-2<br /> - somenamespace<br /><br />Some examples of invalid values are:<br /> - -some-namespace<br /> - some-namespace-<br /> - thisisareallylongnamespacenamethatisgreaterthanthemaximumlength<br /> - some.namespace<br /><br />[RFC 1123]: https://tools.ietf.org/html/rfc1123 | | MaxLength: 63 <br />Pattern: `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$` <br /> |
124124
| `serviceAccount` _[ServiceAccountReference](#serviceaccountreference)_ | serviceAccount is a required reference to a ServiceAccount that exists<br />in the installNamespace. The provided ServiceAccount is used to install and<br />manage the content for the package specified in the packageName field.<br /><br />In order to successfully install and manage the content for the package,<br />the ServiceAccount provided via this field should be configured with the<br />appropriate permissions to perform the necessary operations on all the<br />resources that are included in the bundle of content being applied. | | |
125125
| `preflight` _[PreflightConfig](#preflightconfig)_ | preflight is an optional field that can be used to configure the preflight checks run before installation or upgrade of the content for the package specified in the packageName field.<br /><br />When specified, it overrides the default configuration of the preflight checks that are required to execute successfully during an install/upgrade operation.<br /><br />When not specified, the default configuration for each preflight check will be used. | | |
126+
| `values` _[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#json-v1-apiextensions-k8s-io)_ | values is a map of key-value pairs that provide configuration for the<br />installation of the package specified in the packageName field.<br /><br />It is an optional field.<br /><br />When specified, it is passed to the package manager to be used during the<br />installation process. The package manager is responsible for interpreting<br />the values provided in this field. The bundle that is resolved for the<br />cluster extension may optionally provide a schema for these values. In that<br />case, the package manager will validate the values against the schema before<br />proceeding with the installation.<br /><br />When not specified, the package manager will use the default configuration<br />of the resolved bundle. | | Schemaless: \{\} <br />Type: object <br /> |
126127

127128

128129
#### ClusterExtensionInstallStatus

Diff for: internal/applier/helm.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package applier
33
import (
44
"bytes"
55
"context"
6+
"encoding/json"
67
"errors"
78
"fmt"
89
"io"
@@ -15,15 +16,14 @@ import (
1516
"helm.sh/helm/v3/pkg/postrender"
1617
"helm.sh/helm/v3/pkg/release"
1718
"helm.sh/helm/v3/pkg/storage/driver"
18-
corev1 "k8s.io/api/core/v1"
1919
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2020
apimachyaml "k8s.io/apimachinery/pkg/util/yaml"
2121
"sigs.k8s.io/controller-runtime/pkg/client"
2222

2323
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
2424

2525
ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
26-
"github.com/operator-framework/operator-controller/internal/rukpak/convert"
26+
convert "github.com/operator-framework/operator-controller/internal/rukpak/convert/v2"
2727
"github.com/operator-framework/operator-controller/internal/rukpak/preflights/crdupgradesafety"
2828
"github.com/operator-framework/operator-controller/internal/rukpak/util"
2929
)
@@ -57,11 +57,17 @@ type Helm struct {
5757
}
5858

5959
func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.ClusterExtension, objectLabels map[string]string, storageLabels map[string]string) ([]client.Object, string, error) {
60-
chrt, err := convert.RegistryV1ToHelmChart(ctx, contentFS, ext.Spec.Install.Namespace, []string{corev1.NamespaceAll})
60+
chrt, err := convert.RegistryV1ToHelmChart(ctx, contentFS)
6161
if err != nil {
6262
return nil, "", err
6363
}
64+
6465
values := chartutil.Values{}
66+
if valuesJSON := ext.Spec.Install.Values.Raw; valuesJSON != nil {
67+
if err := json.Unmarshal(valuesJSON, &values); err != nil {
68+
return nil, "", err
69+
}
70+
}
6571

6672
ac, err := h.ActionClientGetter.ActionClientFor(ctx, ext)
6773
if err != nil {
@@ -113,6 +119,7 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust
113119
rel, err = ac.Upgrade(ext.GetName(), ext.Spec.Install.Namespace, chrt, values, func(upgrade *action.Upgrade) error {
114120
upgrade.MaxHistory = maxHelmReleaseHistory
115121
upgrade.Labels = storageLabels
122+
upgrade.ResetValues = true
116123
return nil
117124
}, helmclient.AppendUpgradePostRenderer(post))
118125
if err != nil {
@@ -158,6 +165,7 @@ func (h *Helm) getReleaseState(cl helmclient.ActionInterface, ext *ocv1alpha1.Cl
158165
upgrade.MaxHistory = maxHelmReleaseHistory
159166
upgrade.DryRun = true
160167
upgrade.DryRunOption = "server"
168+
upgrade.ResetValues = true
161169
return nil
162170
}, helmclient.AppendUpgradePostRenderer(post))
163171
if err != nil {

0 commit comments

Comments
 (0)