Merge pull request #101 from jeessy2/master

fix: Add a new parameter "create_namespace"
This commit is contained in:
Joachim Hill-Grannec 2020-08-28 12:09:17 -07:00 committed by GitHub
commit 8dba329407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 28 deletions

View file

@ -1,4 +1,4 @@
FROM alpine/helm:3.1.1 FROM alpine/helm:3.2.4
MAINTAINER Erin Call <erin@liffft.com> MAINTAINER Erin Call <erin@liffft.com>
COPY build/drone-helm /bin/drone-helm COPY build/drone-helm /bin/drone-helm

View file

@ -49,6 +49,7 @@ Installations are triggered when the `mode` setting is "upgrade." They can also
| values_files | list\<string\> | | | Values to use as `--values` arguments to `helm upgrade`. | | values_files | list\<string\> | | | Values to use as `--values` arguments to `helm upgrade`. |
| reuse_values | boolean | | | Reuse the values from a previous release. | | reuse_values | boolean | | | Reuse the values from a previous release. |
| skip_tls_verify | boolean | | | Connect to the Kubernetes cluster without checking for a valid TLS certificate. Not recommended in production. This is ignored if `skip_kubeconfig` is `true`. | | skip_tls_verify | boolean | | | Connect to the Kubernetes cluster without checking for a valid TLS certificate. Not recommended in production. This is ignored if `skip_kubeconfig` is `true`. |
| create_namespace | boolean | | | Pass --create-namespace to `helm upgrade`. |
## Uninstallation ## Uninstallation

View file

@ -33,6 +33,7 @@ type Config struct {
StringValues string `split_words:"true"` // Argument to pass to --set-string in applicable helm commands StringValues string `split_words:"true"` // Argument to pass to --set-string in applicable helm commands
ValuesFiles []string `split_words:"true"` // Arguments to pass to --values in applicable helm commands ValuesFiles []string `split_words:"true"` // Arguments to pass to --values in applicable helm commands
Namespace string `` // Kubernetes namespace for all helm commands Namespace string `` // Kubernetes namespace for all helm commands
CreateNamespace bool `split_words:"true"` // Pass --create-namespace to `helm upgrade`
KubeToken string `split_words:"true"` // Kubernetes authentication token to put in .kube/config KubeToken string `split_words:"true"` // Kubernetes authentication token to put in .kube/config
SkipKubeconfig bool `envconfig:"skip_kubeconfig"` // Skip kubeconfig creation SkipKubeconfig bool `envconfig:"skip_kubeconfig"` // Skip kubeconfig creation
SkipTLSVerify bool `envconfig:"skip_tls_verify"` // Put insecure-skip-tls-verify in .kube/config SkipTLSVerify bool `envconfig:"skip_tls_verify"` // Put insecure-skip-tls-verify in .kube/config

View file

@ -23,6 +23,7 @@ type Upgrade struct {
atomic bool atomic bool
cleanupOnFail bool cleanupOnFail bool
certs *repoCerts certs *repoCerts
createNamespace bool
cmd cmd cmd cmd
} }
@ -45,6 +46,7 @@ func NewUpgrade(cfg env.Config) *Upgrade {
atomic: cfg.AtomicUpgrade, atomic: cfg.AtomicUpgrade,
cleanupOnFail: cfg.CleanupOnFail, cleanupOnFail: cfg.CleanupOnFail,
certs: newRepoCerts(cfg), certs: newRepoCerts(cfg),
createNamespace: cfg.CreateNamespace,
} }
} }
@ -95,6 +97,9 @@ func (u *Upgrade) Prepare() error {
if u.stringValues != "" { if u.stringValues != "" {
args = append(args, "--set-string", u.stringValues) args = append(args, "--set-string", u.stringValues)
} }
if u.createNamespace {
args = append(args, "--create-namespace")
}
for _, vFile := range u.valuesFiles { for _, vFile := range u.valuesFiles {
args = append(args, "--values", vFile) args = append(args, "--values", vFile)
} }