From 1cdd14f640ea2e9492f18c3938f9296b96e2f1d1 Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Tue, 19 Feb 2019 23:01:29 +0100 Subject: [PATCH 1/7] Code to allow flags to helm on global, helm install and helm update level --- pkg/skaffold/deploy/helm.go | 3 +++ pkg/skaffold/schema/latest/config.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 00efbf28872..bfd1970c0dd 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -119,6 +119,7 @@ func (h *HelmDeployer) Cleanup(ctx context.Context, out io.Writer) error { func (h *HelmDeployer) helm(ctx context.Context, out io.Writer, arg ...string) error { args := append([]string{"--kube-context", h.kubeContext}, arg...) + args = append(args, h.Flags.Global...) cmd := exec.CommandContext(ctx, "helm", args...) cmd.Stdout = out @@ -169,8 +170,10 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates var args []string if !isInstalled { args = append(args, "install", "--name", releaseName) + args = append(args, h.Flags.Install...) } else { args = append(args, "upgrade", releaseName) + args = append(args, h.Flags.Upgrade...) if r.RecreatePods { args = append(args, "--recreate-pods") } diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 3e757827351..b728ad62a69 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -331,6 +331,18 @@ type KubectlFlags struct { type HelmDeploy struct { // Releases is a list of Helm releases. Releases []HelmRelease `yaml:"releases,omitempty" yamltags:"required"` + + // Optional flags to send to the helm command + Flags HelmDeployFlags `yaml:"flags,omitempty"` +} + +// HelmDeployFlags describes additional options flags that are passed on the command +// line to helm either on every command (Global), on install (Install) +// or on update (Update). +type HelmDeployFlags struct { + Global []string `yaml:"global,omitempty"` + Install []string `yaml:"apply,omitempty"` + Update []string `yaml:"delete,omitempty"` } // KustomizeDeploy contains the configuration needed for deploying with `kustomize`. From 604dc222b3df91c9ce2655ad921b1b408265ea5e Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Tue, 19 Feb 2019 23:01:43 +0100 Subject: [PATCH 2/7] Update documentation in annotated yaml files --- examples/annotated-skaffold.yaml | 7 +++++++ integration/examples/annotated-skaffold.yaml | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index cba4f108bee..3ac024d87ff 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -195,6 +195,13 @@ deploy: # delete: [""] # helm: + # helm can be passed additional option flags either + # on every command (Global), on install (Install) or on update (Update). + # Note: Parameters can also be set on Release level, but only some flags + # flags: + # global: [""] + # apply: [""] + # delete: [""] # helm releases to deploy. # releases: # - name: skaffold-helm diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml index cba4f108bee..cdbda1f6207 100644 --- a/integration/examples/annotated-skaffold.yaml +++ b/integration/examples/annotated-skaffold.yaml @@ -194,7 +194,13 @@ deploy: # apply: [""] # delete: [""] - # helm: + # helm: + # helm can be passed additional option flags either + # on every command (Global), on install (Install) or on update (Update). + # flags: + # global: [""] + # install: [""] + # update: [""] # helm releases to deploy. # releases: # - name: skaffold-helm From fd2db00a11e76d6055fe809b5ad11778e48313df Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Tue, 19 Feb 2019 23:21:28 +0100 Subject: [PATCH 3/7] Fix update -> upgrade --- examples/annotated-skaffold.yaml | 5 ++--- integration/examples/annotated-skaffold.yaml | 2 +- pkg/skaffold/schema/latest/config.go | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 3ac024d87ff..23b457a09bd 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -197,11 +197,10 @@ deploy: # helm: # helm can be passed additional option flags either # on every command (Global), on install (Install) or on update (Update). - # Note: Parameters can also be set on Release level, but only some flags # flags: # global: [""] - # apply: [""] - # delete: [""] + # install: [""] + # upgrade: [""] # helm releases to deploy. # releases: # - name: skaffold-helm diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml index cdbda1f6207..c20e557f144 100644 --- a/integration/examples/annotated-skaffold.yaml +++ b/integration/examples/annotated-skaffold.yaml @@ -200,7 +200,7 @@ deploy: # flags: # global: [""] # install: [""] - # update: [""] + # upgrade: [""] # helm releases to deploy. # releases: # - name: skaffold-helm diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index b728ad62a69..1054b6de975 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -342,7 +342,7 @@ type HelmDeploy struct { type HelmDeployFlags struct { Global []string `yaml:"global,omitempty"` Install []string `yaml:"apply,omitempty"` - Update []string `yaml:"delete,omitempty"` + Upgrade []string `yaml:"delete,omitempty"` } // KustomizeDeploy contains the configuration needed for deploying with `kustomize`. From 6a528ec128aa213a21e54f44b778f1b953ed5dc4 Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Tue, 19 Feb 2019 23:35:04 +0100 Subject: [PATCH 4/7] Ran make generate-schemas --- schemas/v1beta5.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/schemas/v1beta5.json b/schemas/v1beta5.json index f1c486ad700..829e1e30373 100644 --- a/schemas/v1beta5.json +++ b/schemas/v1beta5.json @@ -493,10 +493,43 @@ }, "type": "array", "description": "a list of Helm releases." + }, + "flags": { + "$ref": "#/definitions/HelmDeployFlags", + "description": "Optional flags to send to the helm command" } }, "description": "contains the configuration needed for deploying with \u003ccode\u003ehelm\u003c/code\u003e." }, + "HelmDeployFlags": { + "properties": { + "global": { + "items": { + "type": "string", + "default": "\"\"" + }, + "type": "array", + "default": "[]" + }, + "apply": { + "items": { + "type": "string", + "default": "\"\"" + }, + "type": "array", + "default": "[]" + }, + "delete": { + "items": { + "type": "string", + "default": "\"\"" + }, + "type": "array", + "default": "[]" + } + }, + "description": "describes additional options flags that are passed on the command line to helm either on every command (Global), on install (Install) or on update (Update)." + }, "KustomizeDeploy": { "properties": { "path": { From 52e919999c5485eb8ffda07e896df83970328b87 Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Tue, 19 Feb 2019 23:43:12 +0100 Subject: [PATCH 5/7] Update should say upgrade --- examples/annotated-skaffold.yaml | 2 +- integration/examples/annotated-skaffold.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 23b457a09bd..1349f022115 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -196,7 +196,7 @@ deploy: # helm: # helm can be passed additional option flags either - # on every command (Global), on install (Install) or on update (Update). + # on every command (Global), on install (Install) or on upgrade (Upgrade). # flags: # global: [""] # install: [""] diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml index c20e557f144..3011b1f002f 100644 --- a/integration/examples/annotated-skaffold.yaml +++ b/integration/examples/annotated-skaffold.yaml @@ -196,7 +196,7 @@ deploy: # helm: # helm can be passed additional option flags either - # on every command (Global), on install (Install) or on update (Update). + # on every command (Global), on install (Install) or on upgrade (Upgrade). # flags: # global: [""] # install: [""] From 3268bc754c4a4a12c7f40aa9c4014fe6b3929dd0 Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Wed, 20 Feb 2019 07:21:59 +0100 Subject: [PATCH 6/7] Annotation was wrong, updated it, regenerated schema --- pkg/skaffold/schema/latest/config.go | 4 ++-- schemas/v1beta5.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 1054b6de975..15bee59ea6e 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -341,8 +341,8 @@ type HelmDeploy struct { // or on update (Update). type HelmDeployFlags struct { Global []string `yaml:"global,omitempty"` - Install []string `yaml:"apply,omitempty"` - Upgrade []string `yaml:"delete,omitempty"` + Install []string `yaml:"install,omitempty"` + Upgrade []string `yaml:"upgrade,omitempty"` } // KustomizeDeploy contains the configuration needed for deploying with `kustomize`. diff --git a/schemas/v1beta5.json b/schemas/v1beta5.json index 829e1e30373..dda5a354d38 100644 --- a/schemas/v1beta5.json +++ b/schemas/v1beta5.json @@ -511,7 +511,7 @@ "type": "array", "default": "[]" }, - "apply": { + "install": { "items": { "type": "string", "default": "\"\"" @@ -519,7 +519,7 @@ "type": "array", "default": "[]" }, - "delete": { + "upgrade": { "items": { "type": "string", "default": "\"\"" From 3c34f41fb7c9306697cb28ffff929fc88a2bae6f Mon Sep 17 00:00:00 2001 From: Tjerk Wolterink Date: Tue, 26 Feb 2019 22:53:57 +0100 Subject: [PATCH 7/7] make generate-schemas --- docs/content/en/schemas/v1beta6.json | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/content/en/schemas/v1beta6.json b/docs/content/en/schemas/v1beta6.json index 881509c2505..c5abe8f0cff 100755 --- a/docs/content/en/schemas/v1beta6.json +++ b/docs/content/en/schemas/v1beta6.json @@ -492,11 +492,42 @@ }, "type": "array", "description": "a list of Helm releases." + }, + "flags": { + "$ref": "#/definitions/HelmDeployFlags", + "description": "Optional flags to send to the helm command" } }, "additionalProperties": false, "description": "(beta) uses the helm CLI to apply the charts to the cluster." }, + "HelmDeployFlags": { + "properties": { + "global": { + "items": { + "type": "string" + }, + "type": "array", + "default": "[]" + }, + "install": { + "items": { + "type": "string" + }, + "type": "array", + "default": "[]" + }, + "upgrade": { + "items": { + "type": "string" + }, + "type": "array", + "default": "[]" + } + }, + "additionalProperties": false, + "description": "describes additional options flags that are passed on the command line to helm either on every command (Global), on install (Install) or on update (Update)." + }, "KustomizeDeploy": { "properties": { "path": {