helmfile should be non-interactive by default (#368)
Request for user confirmation only when a global `--interactive` flag is provided. Resolves #354
This commit is contained in:
parent
76122738c8
commit
98be623701
31
README.md
31
README.md
|
|
@ -170,7 +170,7 @@ releases:
|
||||||
Sync your Kubernetes cluster state to the desired one by running:
|
Sync your Kubernetes cluster state to the desired one by running:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
helmfile sync
|
helmfile apply
|
||||||
```
|
```
|
||||||
|
|
||||||
Congratulations! You now have your first Prometheus deployment running inside your cluster.
|
Congratulations! You now have your first Prometheus deployment running inside your cluster.
|
||||||
|
|
@ -187,19 +187,21 @@ USAGE:
|
||||||
helmfile [global options] command [command options] [arguments...]
|
helmfile [global options] command [command options] [arguments...]
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
repos sync repositories from state file (helm repo add && helm repo update)
|
repos sync repositories from state file (helm repo add && helm repo update)
|
||||||
charts sync releases from state file (helm upgrade --install)
|
charts sync releases from state file (helm upgrade --install)
|
||||||
diff diff releases from state file against env (helm diff)
|
diff diff releases from state file against env (helm diff)
|
||||||
lint lint charts from state file (helm lint)
|
template template releases from state file against env (helm template)
|
||||||
sync sync all resources from state file (repos, releases and chart deps)
|
lint lint charts from state file (helm lint)
|
||||||
apply apply all resources from state file only when there are changes
|
sync sync all resources from state file (repos, releases and chart deps)
|
||||||
status retrieve status of releases in state file
|
apply apply all resources from state file only when there are changes
|
||||||
delete delete releases from state file (helm delete)
|
status retrieve status of releases in state file
|
||||||
test test releases from state file (helm test)
|
delete delete releases from state file (helm delete)
|
||||||
|
test test releases from state file (helm test)
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
--helm-binary value, -b value path to helm binary
|
--helm-binary value, -b value path to helm binary
|
||||||
--file helmfile.yaml, -f helmfile.yaml load config from file or directory. defaults to helmfile.yaml or `helmfile.d`(means `helmfile.d/*.yaml`) in this preference
|
--file helmfile.yaml, -f helmfile.yaml load config from file or directory. defaults to helmfile.yaml or `helmfile.d`(means `helmfile.d/*.yaml`) in this preference
|
||||||
|
--environment default, -e default specify the environment name. defaults to default
|
||||||
--quiet, -q Silence output. Equivalent to log-level warn
|
--quiet, -q Silence output. Equivalent to log-level warn
|
||||||
--kube-context value Set kubectl context. Uses current context by default
|
--kube-context value Set kubectl context. Uses current context by default
|
||||||
--log-level value Set log level, default info
|
--log-level value Set log level, default info
|
||||||
|
|
@ -208,6 +210,7 @@ GLOBAL OPTIONS:
|
||||||
A release must match all labels in a group in order to be used. Multiple groups can be specified at once.
|
A release must match all labels in a group in order to be used. Multiple groups can be specified at once.
|
||||||
--selector tier=frontend,tier!=proxy --selector tier=backend. Will match all frontend, non-proxy releases AND all backend releases.
|
--selector tier=frontend,tier!=proxy --selector tier=backend. Will match all frontend, non-proxy releases AND all backend releases.
|
||||||
The name of a release can be used as a label. --selector name=myrelease
|
The name of a release can be used as a label. --selector name=myrelease
|
||||||
|
--interactive, -i Request confirmation before attempting to modify clusters
|
||||||
--help, -h show help
|
--help, -h show help
|
||||||
--version, -v print the version
|
--version, -v print the version
|
||||||
```
|
```
|
||||||
|
|
@ -707,6 +710,14 @@ set -a; . .env; set +a; helmfile sync
|
||||||
|
|
||||||
Please see #203 for more context.
|
Please see #203 for more context.
|
||||||
|
|
||||||
|
## Running helmfile interactively
|
||||||
|
|
||||||
|
`helmfile --interactive [apply|delete]` requests confirmation from you before actually modifying your cluster.
|
||||||
|
|
||||||
|
Use it when you're running `helmfile` manually on your local machine or a kind of secure administrative hosts.
|
||||||
|
|
||||||
|
For your local use-case, aliasing it like `alias hi='helmfile --interactive'` would be convenient.
|
||||||
|
|
||||||
## Running helmfile without an Internet connection
|
## Running helmfile without an Internet connection
|
||||||
|
|
||||||
Once you download all required charts into your machine, you can run `helmfile charts` to deploy your apps.
|
Once you download all required charts into your machine, you can run `helmfile charts` to deploy your apps.
|
||||||
|
|
|
||||||
20
main.go
20
main.go
|
|
@ -99,6 +99,10 @@ func main() {
|
||||||
--selector tier=frontend,tier!=proxy --selector tier=backend. Will match all frontend, non-proxy releases AND all backend releases.
|
--selector tier=frontend,tier!=proxy --selector tier=backend. Will match all frontend, non-proxy releases AND all backend releases.
|
||||||
The name of a release can be used as a label. --selector name=myrelease`,
|
The name of a release can be used as a label. --selector name=myrelease`,
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "interactive, i",
|
||||||
|
Usage: "Request confirmation before attempting to modify clusters",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Before = configureLogging
|
app.Before = configureLogging
|
||||||
|
|
@ -319,10 +323,6 @@ func main() {
|
||||||
Value: "",
|
Value: "",
|
||||||
Usage: "pass args to helm exec",
|
Usage: "pass args to helm exec",
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "auto-approve",
|
|
||||||
Usage: "Skip interactive approval before applying",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "suppress-secrets",
|
Name: "suppress-secrets",
|
||||||
Usage: "suppress secrets in the diff output. highly recommended to specify on CI/CD use-cases",
|
Usage: "suppress secrets in the diff output. highly recommended to specify on CI/CD use-cases",
|
||||||
|
|
@ -386,8 +386,8 @@ Do you really want to apply?
|
||||||
Helmfile will apply all your changes, as shown above.
|
Helmfile will apply all your changes, as shown above.
|
||||||
|
|
||||||
`, strings.Join(names, "\n"))
|
`, strings.Join(names, "\n"))
|
||||||
autoApprove := c.Bool("auto-approve")
|
interactive := c.GlobalBool("interactive")
|
||||||
if autoApprove || !autoApprove && askForConfirmation(msg) {
|
if !interactive || interactive && askForConfirmation(msg) {
|
||||||
rs := []state.ReleaseSpec{}
|
rs := []state.ReleaseSpec{}
|
||||||
for _, r := range releases {
|
for _, r := range releases {
|
||||||
rs = append(rs, *r)
|
rs = append(rs, *r)
|
||||||
|
|
@ -443,10 +443,6 @@ Do you really want to apply?
|
||||||
Value: "",
|
Value: "",
|
||||||
Usage: "pass args to helm exec",
|
Usage: "pass args to helm exec",
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "auto-approve",
|
|
||||||
Usage: "Skip interactive approval before deleting",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "purge",
|
Name: "purge",
|
||||||
Usage: "purge releases i.e. free release names and histories",
|
Usage: "purge releases i.e. free release names and histories",
|
||||||
|
|
@ -473,8 +469,8 @@ Do you really want to delete?
|
||||||
Helmfile will delete all your releases, as shown above.
|
Helmfile will delete all your releases, as shown above.
|
||||||
|
|
||||||
`, strings.Join(names, "\n"))
|
`, strings.Join(names, "\n"))
|
||||||
autoApprove := c.Bool("auto-approve")
|
interactive := c.GlobalBool("interactive")
|
||||||
if autoApprove || !autoApprove && askForConfirmation(msg) {
|
if !interactive || interactive && askForConfirmation(msg) {
|
||||||
return state.DeleteReleases(helm, purge)
|
return state.DeleteReleases(helm, purge)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue