Support --atomic as a first class directive in helmfile (#491)
Resolves #487
This commit is contained in:
parent
79ae2df71f
commit
f2996e2452
|
|
@ -41,7 +41,7 @@ jobs:
|
||||||
- run:
|
- run:
|
||||||
name: Install helm
|
name: Install helm
|
||||||
environment:
|
environment:
|
||||||
HELM_VERSION: v2.12.0
|
HELM_VERSION: v2.13.0
|
||||||
command: |
|
command: |
|
||||||
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
||||||
curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}"
|
curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ FROM alpine:3.8
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates git bash curl
|
RUN apk add --no-cache ca-certificates git bash curl
|
||||||
|
|
||||||
ARG HELM_VERSION=v2.12.0
|
ARG HELM_VERSION=v2.13.0
|
||||||
ARG HELM_LOCATION="https://kubernetes-helm.storage.googleapis.com"
|
ARG HELM_LOCATION="https://kubernetes-helm.storage.googleapis.com"
|
||||||
ARG HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
ARG HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
||||||
ARG HELM_SHA256="9f96a6e4fc52b5df906da381532cc2eb2f3f57cc203ccaec2b11cf5dc26a7dfc"
|
ARG HELM_SHA256="9f96a6e4fc52b5df906da381532cc2eb2f3f57cc203ccaec2b11cf5dc26a7dfc"
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ releases:
|
||||||
force: true
|
force: true
|
||||||
# set `false` to uninstall on sync
|
# set `false` to uninstall on sync
|
||||||
installed: true
|
installed: true
|
||||||
|
# restores previous state in case of failed release
|
||||||
|
atomic: true
|
||||||
|
|
||||||
# Local chart example
|
# Local chart example
|
||||||
- name: grafana # name of this release
|
- name: grafana # name of this release
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ type HelmSpec struct {
|
||||||
RecreatePods bool `yaml:"recreatePods"`
|
RecreatePods bool `yaml:"recreatePods"`
|
||||||
// Force, when set to true, forces resource update through delete/recreate if needed
|
// Force, when set to true, forces resource update through delete/recreate if needed
|
||||||
Force bool `yaml:"force"`
|
Force bool `yaml:"force"`
|
||||||
|
// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
|
||||||
|
Atomic bool `yaml:"atomic"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepositorySpec that defines values for a helm repo
|
// RepositorySpec that defines values for a helm repo
|
||||||
|
|
@ -96,6 +98,8 @@ type ReleaseSpec struct {
|
||||||
Force *bool `yaml:"force"`
|
Force *bool `yaml:"force"`
|
||||||
// Installed, when set to true, `delete --purge` the release
|
// Installed, when set to true, `delete --purge` the release
|
||||||
Installed *bool `yaml:"installed"`
|
Installed *bool `yaml:"installed"`
|
||||||
|
// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
|
||||||
|
Atomic *bool `yaml:"atomic"`
|
||||||
|
|
||||||
// MissingFileHandler is set to either "Error" or "Warn". "Error" instructs helmfile to fail when unable to find a values or secrets file. When "Warn", it prints the file and continues.
|
// MissingFileHandler is set to either "Error" or "Warn". "Error" instructs helmfile to fail when unable to find a values or secrets file. When "Warn", it prints the file and continues.
|
||||||
// The default value for MissingFileHandler is "Error".
|
// The default value for MissingFileHandler is "Error".
|
||||||
|
|
@ -948,6 +952,10 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
|
||||||
flags = append(flags, "--recreate-pods")
|
flags = append(flags, "--recreate-pods")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if release.Atomic != nil && *release.Atomic || st.HelmDefaults.Atomic {
|
||||||
|
flags = append(flags, "--atomic")
|
||||||
|
}
|
||||||
|
|
||||||
common, err := st.namespaceAndValuesFlags(helm, release)
|
common, err := st.namespaceAndValuesFlags(helm, release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,42 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||||
"--namespace", "test-namespace",
|
"--namespace", "test-namespace",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "atomic",
|
||||||
|
defaults: HelmSpec{
|
||||||
|
Atomic: false,
|
||||||
|
},
|
||||||
|
release: &ReleaseSpec{
|
||||||
|
Chart: "test/chart",
|
||||||
|
Version: "0.1",
|
||||||
|
Atomic: &enable,
|
||||||
|
Name: "test-charts",
|
||||||
|
Namespace: "test-namespace",
|
||||||
|
},
|
||||||
|
want: []string{
|
||||||
|
"--version", "0.1",
|
||||||
|
"--atomic",
|
||||||
|
"--namespace", "test-namespace",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "atomic-from-default",
|
||||||
|
defaults: HelmSpec{
|
||||||
|
Atomic: true,
|
||||||
|
},
|
||||||
|
release: &ReleaseSpec{
|
||||||
|
Chart: "test/chart",
|
||||||
|
Version: "0.1",
|
||||||
|
Atomic: &disable,
|
||||||
|
Name: "test-charts",
|
||||||
|
Namespace: "test-namespace",
|
||||||
|
},
|
||||||
|
want: []string{
|
||||||
|
"--version", "0.1",
|
||||||
|
"--atomic",
|
||||||
|
"--namespace", "test-namespace",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue