Skip to content

Commit dba659e

Browse files
Merge pull request #2216 from justinsb/operator_version
operator: support installation of specific version
2 parents ca68158 + f866d5c commit dba659e

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

operator/config/crd/bases/core.cnrm.cloud.google.com_configconnectorcontexts.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ spec:
9797
- Absent
9898
- Merge
9999
type: string
100+
version:
101+
description: |-
102+
Version specifies the exact addon version to be deployed, eg 1.2.3
103+
Only limited versions are supported; currently we are only supporting
104+
the operator version and the previous minor version.
105+
type: string
100106
required:
101107
- googleServiceAccount
102108
type: object

operator/pkg/apis/core/v1beta1/configconnectorcontext_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import (
2525

2626
// ConfigConnectorContextSpec defines the desired state of ConfigConnectorContext
2727
type ConfigConnectorContextSpec struct {
28+
// Version specifies the exact addon version to be deployed, eg 1.2.3
29+
// Only limited versions are supported; currently we are only supporting
30+
// the operator version and the previous minor version.
31+
Version string `json:"version,omitempty"`
32+
2833
// The Google Service Account to be used by Config Connector to
2934
// authenticate with Google Cloud APIs in the associated namespace.
3035
GoogleServiceAccount string `json:"googleServiceAccount"`

operator/pkg/manifest/per_namespace_manifest_loader.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,27 @@ func NewPerNamespaceManifestLoader(repo Repository) *PerNamespaceManifestLoader
3939
}
4040

4141
func (p *PerNamespaceManifestLoader) ResolveManifest(ctx context.Context, o runtime.Object) (map[string]string, error) {
42-
_, ok := o.(*corev1beta1.ConfigConnectorContext)
42+
ccc, ok := o.(*corev1beta1.ConfigConnectorContext)
4343
if !ok {
4444
return nil, fmt.Errorf("expected the resource to be a ConfigConnectorContext, but it was not. Object: %v", o)
4545
}
4646

4747
componentName := k8s.ConfigConnectorComponentName
4848
channelName := k8s.StableChannel
49-
v, err := ResolveVersion(ctx, p.repo, componentName, channelName)
49+
50+
version := ccc.Spec.Version
51+
if version == "" {
52+
v, err := ResolveVersion(ctx, p.repo, componentName, channelName)
53+
if err != nil {
54+
return nil, fmt.Errorf("error resolving the version for %v in %v channel: %w", componentName, channelName, err)
55+
}
56+
version = v
57+
}
58+
59+
files, err := p.repo.LoadNamespacedComponents(ctx, componentName, version)
5060
if err != nil {
51-
return nil, fmt.Errorf("error resolving the version for %v in %v channel: %w", componentName, channelName, err)
61+
return nil, fmt.Errorf("version %q could not be loaded: %w", version, err)
5262
}
5363

54-
return p.repo.LoadNamespacedComponents(ctx, componentName, v)
64+
return files, nil
5565
}

0 commit comments

Comments
 (0)