src: update CLI help for env flag

Update CLI help for env flag. Now mentioning unsetting of variable.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek 2021-05-13 16:19:22 +02:00 committed by GitHub
parent a72a9a858a
commit a74e3dd5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View File

@ -25,7 +25,9 @@ import (
func init() { func init() {
root.AddCommand(deployCmd) root.AddCommand(deployCmd)
deployCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)") 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("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("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)") deployCmd.Flags().StringP("path", "p", cwd(), "Path to the project directory (Env: $FUNC_PATH)")

View File

@ -13,7 +13,9 @@ import (
func init() { func init() {
// Add the run command as a subcommand of root. // Add the run command as a subcommand of root.
root.AddCommand(runCmd) 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)") runCmd.Flags().StringP("path", "p", cwd(), "Path to the project directory (Env: $FUNC_PATH)")
} }

View File

@ -38,7 +38,7 @@ kn func build [-i <image> -r <registry> -p <path>]
## `run` ## `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. Similar `kn` command: none.
@ -54,7 +54,7 @@ kn func run [-p <path>]
## `deploy` ## `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. 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.

View File

@ -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 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 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 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 ```yaml
env: env:
MODE: debug MODE: debug
API_KEY: {{ env.API_KEY }} API_KEY: {{ env.API_KEY }}
VAR_TO_UNSET-: ""
``` ```
### `image` ### `image`