Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Support loading Helm values from different source types #1836

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
50 changes: 43 additions & 7 deletions chart/flux/templates/helm-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,49 @@ spec:
type: boolean
valueFileSecrets:
type: array
properties:
items:
type: object
required: ['name']
properties:
name:
type: string
items:
type: object
required: ['name']
properties:
name:
type: string
valuesFrom:
type: array
items:
type: object
properties:
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
configMapKeyRef:
type: object
required: ['name']
properties:
name:
type: string
key:
type: string
optional:
type: boolean
secretKeyRef:
type: object
required: ['name']
properties:
name:
type: string
key:
type: string
optional:
type: boolean
externalSourceRef:
type: object
required: ['url']
properties:
url:
type: string
optional:
type: boolean
oneOf:
Copy link
Member

Choose a reason for hiding this comment

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

Ah! I didn't know the directive could go here, but this works.

- required: ['configMapKeyRef']
- required: ['secretKeyRef']
- required: ['externalSourceRef']
values:
type: object
chart:
Expand Down
50 changes: 43 additions & 7 deletions deploy-helm/flux-helm-release-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,49 @@ spec:
type: boolean
valueFileSecrets:
type: array
properties:
items:
type: object
required: ['name']
properties:
name:
type: string
items:
type: object
required: ['name']
properties:
name:
type: string
valuesFrom:
type: array
items:
type: object
properties:
configMapKeyRef:
type: object
required: ['name']
properties:
name:
type: string
key:
type: string
optional:
type: boolean
secretKeyRef:
type: object
required: ['name']
properties:
name:
type: string
key:
type: string
optional:
type: boolean
externalSourceRef:
type: object
required: ['url']
properties:
url:
type: string
optional:
type: boolean
oneOf:
- required: ['configMapKeyRef']
- required: ['secretKeyRef']
- required: ['externalSourceRef']
values:
type: object
chart:
Expand Down
25 changes: 23 additions & 2 deletions integrations/apis/flux.weave.works/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ func (fhr HelmRelease) ResourceID() flux.ResourceID {
return flux.MakeResourceID(fhr.Namespace, "HelmRelease", fhr.Name)
}

// ValuesFromSource represents a source of values.
// Only one of its fields may be set.
type ValuesFromSource struct {
// Selects a key of a ConfigMap.
// +optional
ConfigMapKeyRef *v1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
// Selects a key of a Secret.
// +optional
SecretKeyRef *v1.SecretKeySelector `json:"secretKeyRef,omitempty"`
// Selects an URL.
// +optional
ExternalSourceRef *ExternalSourceSelector `json:"externalSourceRef,omitempty"`
}

type ExternalSourceSelector struct {
URL string `json:"url"`
// Do not fail if external source could not be retrieved
// +optional
Optional *bool `json:"optional,omitempty"`
}

type ChartSource struct {
// one of the following...
// +optional
Expand Down Expand Up @@ -73,12 +94,12 @@ func (s RepoChartSource) CleanRepoURL() string {
return cleanURL + "/"
}

// FluxHelmReleaseSpec is the spec for a FluxHelmRelease resource
// FluxHelmReleaseSpec
// HelmReleaseSpec is the spec for a HelmRelease resource
type HelmReleaseSpec struct {
ChartSource `json:"chart"`
ReleaseName string `json:"releaseName,omitempty"`
ValueFileSecrets []v1.LocalObjectReference `json:"valueFileSecrets,omitempty"`
ValuesFrom []ValuesFromSource `json:"valuesFrom,omitempty"`
HelmValues `json:",inline"`
// Install or upgrade timeout in seconds
// +optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ func (in *ChartSource) DeepCopy() *ChartSource {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalSourceSelector) DeepCopyInto(out *ExternalSourceSelector) {
*out = *in
if in.Optional != nil {
in, out := &in.Optional, &out.Optional
if *in == nil {
*out = nil
} else {
*out = new(bool)
**out = **in
}
}
return
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalSourceSelector.
func (in *ExternalSourceSelector) DeepCopy() *ExternalSourceSelector {
if in == nil {
return nil
}
out := new(ExternalSourceSelector)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitChartSource) DeepCopyInto(out *GitChartSource) {
*out = *in
Expand Down Expand Up @@ -164,6 +189,13 @@ func (in *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) {
*out = make([]v1.LocalObjectReference, len(*in))
copy(*out, *in)
}
if in.ValuesFrom != nil {
in, out := &in.ValuesFrom, &out.ValuesFrom
*out = make([]ValuesFromSource, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
in.HelmValues.DeepCopyInto(&out.HelmValues)
if in.Timeout != nil {
in, out := &in.Timeout, &out.Timeout
Expand Down Expand Up @@ -234,3 +266,46 @@ func (in *RepoChartSource) DeepCopy() *RepoChartSource {
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ValuesFromSource) DeepCopyInto(out *ValuesFromSource) {
*out = *in
if in.ConfigMapKeyRef != nil {
in, out := &in.ConfigMapKeyRef, &out.ConfigMapKeyRef
if *in == nil {
*out = nil
} else {
*out = new(v1.ConfigMapKeySelector)
(*in).DeepCopyInto(*out)
}
}
if in.SecretKeyRef != nil {
in, out := &in.SecretKeyRef, &out.SecretKeyRef
if *in == nil {
*out = nil
} else {
*out = new(v1.SecretKeySelector)
(*in).DeepCopyInto(*out)
}
}
if in.ExternalSourceRef != nil {
in, out := &in.ExternalSourceRef, &out.ExternalSourceRef
if *in == nil {
*out = nil
} else {
*out = new(ExternalSourceSelector)
(*in).DeepCopyInto(*out)
}
}
return
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValuesFromSource.
func (in *ValuesFromSource) DeepCopy() *ValuesFromSource {
if in == nil {
return nil
}
out := new(ValuesFromSource)
in.DeepCopyInto(out)
return out
}
Loading