Fix ability to unset ApplicationSource specific parameters (#1041)

This commit is contained in:
Jesse Suen 2019-01-17 19:38:35 -08:00 committed by GitHub
parent 8da5fd9bb7
commit ea428eb722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -421,6 +421,10 @@ func setKsonnetOpt(src *argoappv1.ApplicationSource, env *string) {
}
if env != nil {
src.Ksonnet.Environment = *env
src.Environment = *env
}
if src.Ksonnet.IsZero() {
src.Ksonnet = nil
}
}
@ -431,6 +435,9 @@ func setKustomizeOpt(src *argoappv1.ApplicationSource, namePrefix *string) {
if namePrefix != nil {
src.Kustomize.NamePrefix = *namePrefix
}
if src.Kustomize.IsZero() {
src.Kustomize = nil
}
}
func setHelmOpt(src *argoappv1.ApplicationSource, valueFiles []string) {
@ -439,6 +446,10 @@ func setHelmOpt(src *argoappv1.ApplicationSource, valueFiles []string) {
}
if valueFiles != nil {
src.Helm.ValueFiles = valueFiles
src.ValuesFiles = valueFiles
}
if src.Helm.IsZero() {
src.Helm = nil
}
}

View file

@ -91,18 +91,30 @@ type ApplicationSourceHelm struct {
ValueFiles []string `json:"valueFiles,omitempty" protobuf:"bytes,1,opt,name=valueFiles"`
}
func (h *ApplicationSourceHelm) IsZero() bool {
return len(h.ValueFiles) == 0
}
// ApplicationSourceKustomize holds kustomize specific options
type ApplicationSourceKustomize struct {
// NamePrefix is a prefix appended to resources for kustomize apps
NamePrefix string `json:"namePrefix" protobuf:"bytes,1,opt,name=namePrefix"`
}
func (k *ApplicationSourceKustomize) IsZero() bool {
return k.NamePrefix == ""
}
// ApplicationSourceKsonnet holds ksonnet specific options
type ApplicationSourceKsonnet struct {
// Environment is a ksonnet application environment name
Environment string `json:"environment,omitempty" protobuf:"bytes,1,opt,name=environment"`
}
func (k *ApplicationSourceKsonnet) IsZero() bool {
return k.Environment == ""
}
// ApplicationDestination contains deployment destination information
type ApplicationDestination struct {
// Server overrides the environment server value in the ksonnet app.yaml