Skip to content

Commit

Permalink
Merge pull request #2216 from justinsb/operator_version
Browse files Browse the repository at this point in the history
operator: support installation of specific version
  • Loading branch information
google-oss-prow[bot] authored Jul 3, 2024
2 parents ca68158 + f866d5c commit dba659e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ spec:
- Absent
- Merge
type: string
version:
description: |-
Version specifies the exact addon version to be deployed, eg 1.2.3
Only limited versions are supported; currently we are only supporting
the operator version and the previous minor version.
type: string
required:
- googleServiceAccount
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import (

// ConfigConnectorContextSpec defines the desired state of ConfigConnectorContext
type ConfigConnectorContextSpec struct {
// Version specifies the exact addon version to be deployed, eg 1.2.3
// Only limited versions are supported; currently we are only supporting
// the operator version and the previous minor version.
Version string `json:"version,omitempty"`

// The Google Service Account to be used by Config Connector to
// authenticate with Google Cloud APIs in the associated namespace.
GoogleServiceAccount string `json:"googleServiceAccount"`
Expand Down
18 changes: 14 additions & 4 deletions operator/pkg/manifest/per_namespace_manifest_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,27 @@ func NewPerNamespaceManifestLoader(repo Repository) *PerNamespaceManifestLoader
}

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

componentName := k8s.ConfigConnectorComponentName
channelName := k8s.StableChannel
v, err := ResolveVersion(ctx, p.repo, componentName, channelName)

version := ccc.Spec.Version
if version == "" {
v, err := ResolveVersion(ctx, p.repo, componentName, channelName)
if err != nil {
return nil, fmt.Errorf("error resolving the version for %v in %v channel: %w", componentName, channelName, err)
}
version = v
}

files, err := p.repo.LoadNamespacedComponents(ctx, componentName, version)
if err != nil {
return nil, fmt.Errorf("error resolving the version for %v in %v channel: %w", componentName, channelName, err)
return nil, fmt.Errorf("version %q could not be loaded: %w", version, err)
}

return p.repo.LoadNamespacedComponents(ctx, componentName, v)
return files, nil
}

0 comments on commit dba659e

Please sign in to comment.