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

Commit

Permalink
feat: Add configurable Helm version (argoproj#4111)
Browse files Browse the repository at this point in the history
This commit adds support for configurable Helm version either via
declarative syntax or via argocd cli.

New helm option 'Version' added to the ApplicationSourceHelm
struct which can be either 'v2' or 'v3'.

Argocd app create accepts '--helm-version' that also looks for the
same Helm versions as above.
  • Loading branch information
loxley authored and Jon Walton committed Oct 27, 2020
1 parent 6929423 commit 4777867
Show file tree
Hide file tree
Showing 18 changed files with 598 additions and 384 deletions.
4 changes: 4 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3800,6 +3800,10 @@
"values": {
"type": "string",
"title": "Values is Helm values, typically defined as a block"
},
"version": {
"type": "string",
"title": "Version is the Helm version to use for templating with"
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ func setAppSpecOptions(flags *pflag.FlagSet, spec *argoappv1.ApplicationSpec, ap
setHelmOpt(&spec.Source, helmOpts{values: string(data)})
case "release-name":
setHelmOpt(&spec.Source, helmOpts{releaseName: appOpts.releaseName})
case "helm-version":
setHelmOpt(&spec.Source, helmOpts{version: appOpts.helmVersion})
case "helm-set":
setHelmOpt(&spec.Source, helmOpts{helmSets: appOpts.helmSets})
case "helm-set-string":
Expand Down Expand Up @@ -655,6 +657,7 @@ type helmOpts struct {
valueFiles []string
values string
releaseName string
version string
helmSets []string
helmSetStrings []string
helmSetFiles []string
Expand All @@ -673,6 +676,9 @@ func setHelmOpt(src *argoappv1.ApplicationSource, opts helmOpts) {
if opts.releaseName != "" {
src.Helm.ReleaseName = opts.releaseName
}
if opts.version != "" {
src.Helm.Version = opts.version
}
for _, text := range opts.helmSets {
p, err := argoappv1.NewHelmParameter(text, false)
if err != nil {
Expand Down Expand Up @@ -740,6 +746,7 @@ type appOptions struct {
helmSets []string
helmSetStrings []string
helmSetFiles []string
helmVersion string
project string
syncPolicy string
syncOptions []string
Expand Down Expand Up @@ -773,6 +780,7 @@ func addAppFlags(command *cobra.Command, opts *appOptions) {
command.Flags().StringArrayVar(&opts.valuesFiles, "values", []string{}, "Helm values file(s) to use")
command.Flags().StringVar(&opts.values, "values-literal-file", "", "Filename or URL to import as a literal Helm values block")
command.Flags().StringVar(&opts.releaseName, "release-name", "", "Helm release-name")
command.Flags().StringVar(&opts.helmVersion, "helm-version", "", "Helm version")
command.Flags().StringArrayVar(&opts.helmSets, "helm-set", []string{}, "Helm set values on the command line (can be repeated to set several values: --helm-set key1=val1 --helm-set key2=val2)")
command.Flags().StringArrayVar(&opts.helmSetStrings, "helm-set-string", []string{}, "Helm set STRING values on the command line (can be repeated to set several values: --helm-set-string key1=val1 --helm-set-string key2=val2)")
command.Flags().StringArrayVar(&opts.helmSetFiles, "helm-set-file", []string{}, "Helm set values from respective files specified via the command line (can be repeated to set several values: --helm-set-file key1=path1 --helm-set-file key2=path2)")
Expand Down
5 changes: 5 additions & 0 deletions cmd/argocd/commands/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func Test_setHelmOpt(t *testing.T) {
setHelmOpt(&src, helmOpts{helmSetFiles: []string{"foo=bar"}})
assert.Equal(t, []v1alpha1.HelmFileParameter{{Name: "foo", Path: "bar"}}, src.Helm.FileParameters)
})
t.Run("Version", func(t *testing.T) {
src := v1alpha1.ApplicationSource{}
setHelmOpt(&src, helmOpts{version: "v3"})
assert.Equal(t, "v3", src.Helm.Version)
})
}

func Test_setJsonnetOpt(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
Expand Down
18 changes: 18 additions & 0 deletions manifests/crds/application-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -464,6 +467,9 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -735,6 +741,9 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1012,6 +1021,9 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1267,6 +1279,9 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1519,6 +1534,9 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down
24 changes: 24 additions & 0 deletions manifests/ha/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ spec:
description: Values is Helm values, typically defined as
a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -526,6 +530,10 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -827,6 +835,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1149,6 +1161,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use
for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1448,6 +1464,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1734,6 +1754,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down
24 changes: 24 additions & 0 deletions manifests/ha/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ spec:
description: Values is Helm values, typically defined as
a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -526,6 +530,10 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -827,6 +835,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1149,6 +1161,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use
for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1448,6 +1464,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1734,6 +1754,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down
24 changes: 24 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ spec:
description: Values is Helm values, typically defined as
a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -526,6 +530,10 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -827,6 +835,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1149,6 +1161,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use
for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1448,6 +1464,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1734,6 +1754,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down
24 changes: 24 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ spec:
description: Values is Helm values, typically defined as
a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -526,6 +530,10 @@ spec:
values:
description: Values is Helm values, typically defined as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -827,6 +835,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for templating
with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1149,6 +1161,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use
for templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1448,6 +1464,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down Expand Up @@ -1734,6 +1754,10 @@ spec:
description: Values is Helm values, typically defined
as a block
type: string
version:
description: Version is the Helm version to use for
templating with
type: string
type: object
ksonnet:
description: Ksonnet holds ksonnet specific options
Expand Down
Loading

0 comments on commit 4777867

Please sign in to comment.