Merge pull request #222 from mumoshu/wait-for-release
feat: `wait: true` in each release
This commit is contained in:
commit
0541731350
29
README.md
29
README.md
|
|
@ -44,11 +44,9 @@ helmDefaults:
|
|||
tillerNamespace: tiller-namespace #dedicated default key for tiller-namespace
|
||||
kubeContext: kube-context #dedicated default key for kube-context
|
||||
args:
|
||||
- "--wait"
|
||||
- "--recreate-pods"
|
||||
- "--timeout=600"
|
||||
- "--force"
|
||||
- "--reset-values"
|
||||
|
||||
releases:
|
||||
# Published chart example
|
||||
|
|
@ -59,21 +57,23 @@ releases:
|
|||
chart: roboll/vault-secret-manager # the chart being installed to create this release, referenced by `repository/chart` syntax
|
||||
version: ~1.24.1 # the semver of the chart. range constraint is supported
|
||||
values:
|
||||
- vault.yaml # value files (--values)
|
||||
- db: # inline values. Passed via a temporary values file (--values)
|
||||
# value files passed via --values
|
||||
- vault.yaml
|
||||
# inline values, passed via a temporary values file and --values
|
||||
- address: https://vault.example.com
|
||||
db:
|
||||
username: {{ requiredEnv "DB_USERNAME" }}
|
||||
# value taken from environment variable. Quotes are necessary. Will throw an error if the environment variable is not set. $DB_PASSWORD needs to be set in the calling environment ex: export DB_PASSWORD='password1'
|
||||
password: {{ requiredEnv "DB_PASSWORD" }}
|
||||
proxy:
|
||||
# Interpolate environment variable with a fixed string
|
||||
domain: {{ requiredEnv "PLATFORM_ID" }}.my-domain.com
|
||||
scheme: {{ env "SCHEME" | default "https" }}
|
||||
# will attempt to decrypt it using helm-secrets plugin
|
||||
secrets:
|
||||
- vault_secret.yaml # will attempt to decrypt it using helm-secrets plugin
|
||||
set: # values (--set)
|
||||
- name: address
|
||||
value: https://vault.example.com
|
||||
- name: db.password
|
||||
value: {{ requiredEnv "DB_PASSWORD" }} # value taken from environment variable. Quotes are necessary. Will throw an error if the environment variable is not set. $DB_PASSWORD needs to be set in the calling environment ex: export DB_PASSWORD='password1'
|
||||
- name: proxy.domain
|
||||
value: {{ requiredEnv "PLATFORM_ID" }}.my-domain.com # Interpolate environment variable with a fixed string
|
||||
- name: proxy.scheme
|
||||
value: {{ env "SCHEME" | default "https" }}
|
||||
- vault_secret.yaml
|
||||
# wait for k8s resources via --wait. Defaults to `false`
|
||||
wait: true
|
||||
|
||||
# Local chart example
|
||||
- name: grafana # name of this release
|
||||
|
|
@ -82,6 +82,7 @@ releases:
|
|||
values:
|
||||
- "../../my-values/grafana/values.yaml" # Values file (relative path to manifest)
|
||||
- ./values/{{ requiredEnv "PLATFORM_ENV" }}/config.yaml # Values file taken from path with environment variable. $PLATFORM_ENV must be set in the calling environment.
|
||||
wait: true
|
||||
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ type ReleaseSpec struct {
|
|||
Chart string `yaml:"chart"`
|
||||
Version string `yaml:"version"`
|
||||
Verify bool `yaml:"verify"`
|
||||
Wait bool `yaml:"wait"`
|
||||
|
||||
// Name is the name of this release
|
||||
Name string `yaml:"name"`
|
||||
|
|
@ -215,7 +216,7 @@ func (state *HelmState) SyncReleases(helm helmexec.Interface, additionalValues [
|
|||
go func() {
|
||||
for release := range jobQueue {
|
||||
state.applyDefaultsTo(release)
|
||||
flags, flagsErr := state.flagsForRelease(helm, state.BaseChartPath, release)
|
||||
flags, flagsErr := state.flagsForUpgrade(helm, state.BaseChartPath, release)
|
||||
if flagsErr != nil {
|
||||
errQueue <- flagsErr
|
||||
doneQueue <- true
|
||||
|
|
@ -295,7 +296,7 @@ func (state *HelmState) DiffReleases(helm helmexec.Interface, additionalValues [
|
|||
|
||||
state.applyDefaultsTo(release)
|
||||
|
||||
flags, err := state.flagsForRelease(helm, state.BaseChartPath, release)
|
||||
flags, err := state.flagsForDiff(helm, state.BaseChartPath, release)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
|
@ -379,7 +380,7 @@ func (state *HelmState) LintReleases(helm helmexec.Interface, additionalValues [
|
|||
go func() {
|
||||
for release := range jobQueue {
|
||||
errs := []error{}
|
||||
flags, err := state.flagsForRelease(helm, state.BaseChartPath, release)
|
||||
flags, err := state.flagsForLint(helm, state.BaseChartPath, release)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
|
@ -417,21 +418,8 @@ func (state *HelmState) LintReleases(helm helmexec.Interface, additionalValues [
|
|||
chartPath = path.Join(chartPath, chartNameWithoutRepository(release.Chart))
|
||||
}
|
||||
|
||||
// strip version from the slice returned from flagsForRelease
|
||||
realFlags := []string{}
|
||||
isVersion := false
|
||||
for _, v := range flags {
|
||||
if v == "--version" {
|
||||
isVersion = true
|
||||
} else if isVersion {
|
||||
isVersion = false
|
||||
} else {
|
||||
realFlags = append(realFlags, v)
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) == 0 {
|
||||
if err := helm.Lint(chartPath, realFlags...); err != nil {
|
||||
if err := helm.Lint(chartPath, flags...); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
|
@ -663,14 +651,42 @@ func chartNameWithoutRepository(chart string) string {
|
|||
return chartSplit[len(chartSplit)-1]
|
||||
}
|
||||
|
||||
func (state *HelmState) flagsForRelease(helm helmexec.Interface, basePath string, release *ReleaseSpec) ([]string, error) {
|
||||
func (state *HelmState) flagsForUpgrade(helm helmexec.Interface, basePath string, release *ReleaseSpec) ([]string, error) {
|
||||
flags := []string{}
|
||||
if release.Verify {
|
||||
flags = append(flags, "--verify")
|
||||
}
|
||||
if release.Wait {
|
||||
flags = append(flags, "--wait")
|
||||
}
|
||||
if release.Version != "" {
|
||||
flags = append(flags, "--version", release.Version)
|
||||
}
|
||||
common, err := state.namespaceAndValuesFlags(helm, basePath, release)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(flags, common...), nil
|
||||
}
|
||||
|
||||
func (state *HelmState) flagsForDiff(helm helmexec.Interface, basePath string, release *ReleaseSpec) ([]string, error) {
|
||||
flags := []string{}
|
||||
if release.Version != "" {
|
||||
flags = append(flags, "--version", release.Version)
|
||||
}
|
||||
if release.Verify {
|
||||
flags = append(flags, "--verify")
|
||||
common, err := state.namespaceAndValuesFlags(helm, basePath, release)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(flags, common...), nil
|
||||
}
|
||||
|
||||
func (state *HelmState) flagsForLint(helm helmexec.Interface, basePath string, release *ReleaseSpec) ([]string, error) {
|
||||
return state.namespaceAndValuesFlags(helm, basePath, release)
|
||||
}
|
||||
|
||||
func (state *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, basePath string, release *ReleaseSpec) ([]string, error) {
|
||||
flags := []string{}
|
||||
if release.Namespace != "" {
|
||||
flags = append(flags, "--namespace", release.Namespace)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue