Skip to content

🌱 Helm extension prototype #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions api/v1alpha1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ type ClusterExtensionInstallConfig struct {
// resources that are included in the bundle of content being applied.
ServiceAccount ServiceAccountReference `json:"serviceAccount"`

// configMap is an optional field that can be used to reference a configMap
// configSource is an optional field that can be used to reference a configMap
// containing helm values when installing an extension that is packaged as a helm chart
//
//+optional
ConfigMap *ConfigMapReference `json:"configMap,omitempty"`
ConfigSources *ConfigSourceReferences `json:"configMap,omitempty"`

// 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.
//
Expand Down Expand Up @@ -382,9 +382,11 @@ type ServiceAccountReference struct {
Name string `json:"name"`
}

// ConfigMapReference references a configMap
type ConfigMapReference struct {
Name string `json:"name"`
// ConfigSourceReference can references a configMap, a secret, plain text config
type ConfigSourceReferences struct {
ConfigMapNames []string `json:"configMapNames,omitempty"`
SecretNames []string `json:"secretNames,omitempty"`
TextConfigs []string `json:"textConfigs,omitempty"`
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you did something like a discriminated union here?

I'm thinking something like:

type ConfigSourceType string

const (
  ConfigSourceTypeConfigMap = "ConfigMap"
  ConfigSourceTypeSecret = "Secret"
  ConfigSourceTypeInline = "Inline" 
)

// CEL validation here to ensure type + property correctness
type ConfigSource struct {
  // +required
  Type ConfigSourceType `json:"type"`
  // +optional
  ConfigMap *ConfigMapReference `json:"configMap,omitempty"`
  ...
}

Then line 149 could become:

ConfigSources []ConfigSource

I think something like this might fit better with the existing conventions of the ClusterExtension API


// PreflightConfig holds the configuration for the preflight checks. If used, at least one preflight check must be non-nil.
Expand Down
31 changes: 23 additions & 8 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ func main() {
},
Applier: &applier.Helmer{
ActionClientGetter: phg,
ConfigMapName: "",
Namespace: "",
Client: cl,
TokenGetter: tokenGetter,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ spec:
properties:
configMap:
description: |-
configMap is an optional field that can be used to reference a configMap
configSource is an optional field that can be used to reference a configMap
containing helm values when installing an extension that is packaged as a helm chart
properties:
name:
type: string
required:
- name
configMapNames:
items:
type: string
type: array
secretNames:
items:
type: string
type: array
textConfigs:
items:
type: string
type: array
type: object
namespace:
description: |-
Expand Down
5 changes: 3 additions & 2 deletions config/samples/metrics-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ spec:
namespace: metrics-server
serviceAccount:
name: metrics-server-installer
configMap:
name: values
configSources:
configMaps:
- "values"
Loading