6 Commits

Author SHA1 Message Date
Joachim Hill-Grannec
7c033a8b0a Merge pull request #104 from georgekaz/add-skip-crds
add skip-crds flag support
2021-07-21 08:10:35 -06:00
George Kaz
e482a144c1 add skip-crds flag support
Signed-off-by: George Kaz <egeorgekaz@gmail.com>
2021-07-20 19:26:00 +01:00
Joachim Hill-Grannec
8dba329407 Merge pull request #101 from jeessy2/master
fix: Add a new parameter "create_namespace"
2020-08-28 12:09:17 -07:00
Joachim Hill-Grannec
4462307983 Merge branch 'master' into master 2020-08-26 10:15:24 -07:00
jie
1809d7b133 upgrade helm to 3.2.4, kubernetes needs 1.8+ 2020-08-19 13:36:30 +08:00
jie
70b2a2d0b4 Add a parameter "create_namespace" 2020-08-19 11:11:11 +08:00
5 changed files with 66 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
FROM alpine/helm:3.1.1 FROM alpine/helm:3.6.2
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,8 @@ 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`. |
| skip_crds | boolean | | | Pass --skip-crds 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
@@ -51,6 +52,7 @@ type Config struct {
AtomicUpgrade bool `split_words:"true"` // Pass --atomic to `helm upgrade` AtomicUpgrade bool `split_words:"true"` // Pass --atomic to `helm upgrade`
CleanupOnFail bool `envconfig:"cleanup_failed_upgrade"` // Pass --cleanup-on-fail to `helm upgrade` CleanupOnFail bool `envconfig:"cleanup_failed_upgrade"` // Pass --cleanup-on-fail to `helm upgrade`
LintStrictly bool `split_words:"true"` // Pass --strict to `helm lint` LintStrictly bool `split_words:"true"` // Pass --strict to `helm lint`
SkipCrds bool `split_words:"true"` // Pass --skip-crds to `helm upgrade`
Stdout io.Writer `ignored:"true"` Stdout io.Writer `ignored:"true"`
Stderr io.Writer `ignored:"true"` Stderr io.Writer `ignored:"true"`

View File

@@ -23,6 +23,8 @@ type Upgrade struct {
atomic bool atomic bool
cleanupOnFail bool cleanupOnFail bool
certs *repoCerts certs *repoCerts
createNamespace bool
skipCrds bool
cmd cmd cmd cmd
} }
@@ -45,6 +47,8 @@ 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,
skipCrds: cfg.SkipCrds,
} }
} }
@@ -95,6 +99,12 @@ 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")
}
if u.skipCrds {
args = append(args, "--skip-crds")
}
for _, vFile := range u.valuesFiles { for _, vFile := range u.valuesFiles {
args = append(args, "--values", vFile) args = append(args, "--values", vFile)
} }

View File

@@ -220,3 +220,27 @@ func (suite *UpgradeTestSuite) TestPrepareDebugFlag() {
suite.Equal(want, stderr.String()) suite.Equal(want, stderr.String())
suite.Equal("", stdout.String()) suite.Equal("", stdout.String())
} }
func (suite *UpgradeTestSuite) TestPrepareSkipCrdsFlag() {
defer suite.ctrl.Finish()
cfg := env.Config{
Chart: "at40",
Release: "cabbages_smell_great",
SkipCrds: true,
}
u := NewUpgrade(cfg)
command = func(path string, args ...string) cmd {
suite.Equal(helmBin, path)
suite.Equal([]string{"upgrade", "--install", "--skip-crds", "cabbages_smell_great", "at40"}, args)
return suite.mockCmd
}
suite.mockCmd.EXPECT().Stdout(gomock.Any())
suite.mockCmd.EXPECT().Stderr(gomock.Any())
err := u.Prepare()
suite.Require().Nil(err)
}