From a74e3dd5e8f44c06dbaab8c9df1f87ea63e5413d Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Thu, 13 May 2021 16:19:22 +0200 Subject: [PATCH] src: update CLI help for env flag Update CLI help for env flag. Now mentioning unsetting of variable. Signed-off-by: Matej Vasek --- cmd/deploy.go | 4 +++- cmd/run.go | 4 +++- docs/guides/commands.md | 4 ++-- docs/guides/func_yaml.md | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/deploy.go b/cmd/deploy.go index 72088e60..31bfaec4 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -25,7 +25,9 @@ import ( func init() { root.AddCommand(deployCmd) deployCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)") - deployCmd.Flags().StringArrayP("env", "e", []string{}, "Environment variable to set in the form NAME=VALUE. You may provide this flag multiple times for setting multiple environment variables.") + deployCmd.Flags().StringArrayP("env", "e", []string{}, "Environment variable to set in the form NAME=VALUE. " + + "You may provide this flag multiple times for setting multiple environment variables. " + + "To unset, specify the environment variable name followed by a \"-\" (e.g., NAME-).") deployCmd.Flags().StringP("image", "i", "", "Full image name in the form [registry]/[namespace]/[name]:[tag] (optional). This option takes precedence over --registry (Env: $FUNC_IMAGE") deployCmd.Flags().StringP("namespace", "n", "", "Namespace of the function to undeploy. By default, the namespace in func.yaml is used or the actual active namespace if not set in the configuration. (Env: $FUNC_NAMESPACE)") deployCmd.Flags().StringP("path", "p", cwd(), "Path to the project directory (Env: $FUNC_PATH)") diff --git a/cmd/run.go b/cmd/run.go index 23a42b33..b5b4a1ed 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -13,7 +13,9 @@ import ( func init() { // Add the run command as a subcommand of root. root.AddCommand(runCmd) - runCmd.Flags().StringArrayP("env", "e", []string{}, "Environment variable to set in the form NAME=VALUE. You may provide this flag multiple times for setting multiple environment variables.") + runCmd.Flags().StringArrayP("env", "e", []string{}, "Environment variable to set in the form NAME=VALUE. " + + "You may provide this flag multiple times for setting multiple environment variables. " + + "To unset, specify the environment variable name followed by a \"-\" (e.g., NAME-).") runCmd.Flags().StringP("path", "p", cwd(), "Path to the project directory (Env: $FUNC_PATH)") } diff --git a/docs/guides/commands.md b/docs/guides/commands.md index a52f7cd3..bd08a78a 100644 --- a/docs/guides/commands.md +++ b/docs/guides/commands.md @@ -38,7 +38,7 @@ kn func build [-i -r -p ] ## `run` -Runs the Function project locally in the container. If a container has not yet been created, prompts the user to run `func build`. The user may specify a path to the project directory using the `--path` or `-p` flag. +Runs the Function project locally in the container. If a container has not yet been created, prompts the user to run `func build`. The user may specify a path to the project directory using the `--path` or `-p` flag. The user may set an environment variable by using `--env` or `-e` flag, e.g. `-e VAR_NAME=VAR_VALUE`. To unset a variable dash `-` suffix is used, e.g. `-e VAR_NAME-`. Similar `kn` command: none. @@ -54,7 +54,7 @@ kn func run [-p ] ## `deploy` -Deploys the Function project in the current directory. The user may specify a path to the project directory using the `--path` or `-p` flag. Reads the `func.yaml` configuration file to determine the image name. An image and registry may be specified on the command line using the `--image` or `-i` and `--registry` or `-r` flag. +Deploys the Function project in the current directory. The user may specify a path to the project directory using the `--path` or `-p` flag. Reads the `func.yaml` configuration file to determine the image name. An image and registry may be specified on the command line using the `--image` or `-i` and `--registry` or `-r` flag. The user may set an environment variable by using `--env` or `-e` flag, e.g. `-e VAR_NAME=VAR_VALUE`. To unset a variable dash `-` suffix is used, e.g. `-e VAR_NAME-`. Derives the service name from the project name. There is no mechanism by which the user can specify the service name. The user must have already initialized the function using `func create` or they will encounter an error. diff --git a/docs/guides/func_yaml.md b/docs/guides/func_yaml.md index 5275e85e..4dbc4c80 100644 --- a/docs/guides/func_yaml.md +++ b/docs/guides/func_yaml.md @@ -33,12 +33,13 @@ it's typically unnecessary to modify the `builder` field, using values from The `env` field allows you to set environment variables that will be available to your function at runtime. For example, to set a `MODE` environment variable to `debug` when the function is deployed, your `func.yaml` file -may look like this. +may look like this. To unset variables use a dash suffix. For example, to unset `MODE`, use `MODE-`. ```yaml env: MODE: debug API_KEY: {{ env.API_KEY }} + VAR_TO_UNSET-: "" ``` ### `image`