mirror of https://github.com/knative/client.git
feat(XDG home): use XDG_CONFIG_HOME as default config location (#668)
* feat(XDG home): use XDG_CONFIG_HOME as default config location * fix: typo in comment * feat(XDG home): update readme and usage strings
This commit is contained in:
parent
66173059fc
commit
034a9b387e
|
|
@ -42,13 +42,13 @@ There are a set of configuration parameters you can setup to better customize `k
|
||||||
|
|
||||||
### Location
|
### Location
|
||||||
|
|
||||||
The default location `kn` looks for config is under the home directory of the user at `$HOME/.kn/config.yaml`. It is not created for you as part of the `kn` installation. You can create this file elsewhere and use the `--config` flag to specify its path.
|
The default location `kn` looks for config is under the home directory of the user at `$HOME/.config/kn/config.yaml`. It is not created for you as part of the `kn` installation. You can create this file elsewhere and use the `--config` flag to specify its path.
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
Below are the options you can specify in the `kn` config file.
|
Below are the options you can specify in the `kn` config file.
|
||||||
|
|
||||||
1. `pluginsDir` which is the same as the persistent flag `--plugins-dir` and specifies the kn plugins directory. It defaults to: `~/.kn/plugins`. By using the persistent flag (when you issue a command) or by specifying the value in the `kn` config, a user can select which directory to find `kn` plugins. It can be any directory that is visible to the user.
|
1. `pluginsDir` which is the same as the persistent flag `--plugins-dir` and specifies the kn plugins directory. It defaults to: `~/.config/kn/plugins`. By using the persistent flag (when you issue a command) or by specifying the value in the `kn` config, a user can select which directory to find `kn` plugins. It can be any directory that is visible to the user.
|
||||||
|
|
||||||
2. `lookupPluginsInPath` which is the same as the persistent flag `--lookup-plugins-in-path` and specficies if `kn` should look for plugins anywhere in the specified `PATH` environment variable. This is a boolean configuration option and the default value is `false`.
|
2. `lookupPluginsInPath` which is the same as the persistent flag `--lookup-plugins-in-path` and specficies if `kn` should look for plugins anywhere in the specified `PATH` environment variable. This is a boolean configuration option and the default value is `false`.
|
||||||
|
|
||||||
|
|
@ -58,13 +58,13 @@ Below are the options you can specify in the `kn` config file.
|
||||||
3. `version`: The version of Kubernetes resources.
|
3. `version`: The version of Kubernetes resources.
|
||||||
4. `resource`: The plural name of Kubernetes resources (for example: services).
|
4. `resource`: The plural name of Kubernetes resources (for example: services).
|
||||||
|
|
||||||
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`.
|
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/kn/.config/plugins`.
|
||||||
It also defines a sink prefix `myprefix` which refers to `brokers` in `eventing.knative.dev/v1alpha1`. With this configuration, you can use `myprefix:default` to describe a Broker `default` in `kn` command line.
|
It also defines a sink prefix `myprefix` which refers to `brokers` in `eventing.knative.dev/v1alpha1`. With this configuration, you can use `myprefix:default` to describe a Broker `default` in `kn` command line.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cat ~/.kn/config.yaml
|
cat ~/.config/kn/config.yaml
|
||||||
lookupPluginsInPath: true
|
lookupPluginsInPath: true
|
||||||
pluginsdir: ~/.kn/plugins
|
pluginsdir: ~/.config/kn/plugins
|
||||||
sink:
|
sink:
|
||||||
- prefix: myprefix
|
- prefix: myprefix
|
||||||
group: eventing.knative.dev
|
group: eventing.knative.dev
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ Manage your Knative building blocks:
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
-h, --help help for kn
|
-h, --help help for kn
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
--lookup-plugins look for kn plugins in $PATH
|
--lookup-plugins look for kn plugins in $PATH
|
||||||
--plugins-dir string kn plugins directory (default "~/.kn/plugins")
|
--plugins-dir string kn plugins directory (default "~/.config/kn/plugins")
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ kn completion [SHELL] [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ kn plugin [flags]
|
||||||
```
|
```
|
||||||
-h, --help help for plugin
|
-h, --help help for plugin
|
||||||
--lookup-plugins look for kn plugins in $PATH
|
--lookup-plugins look for kn plugins in $PATH
|
||||||
--plugins-dir string kn plugins directory (default "~/.kn/plugins")
|
--plugins-dir string kn plugins directory (default "~/.config/kn/plugins")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ List all installed plugins.
|
||||||
Available plugins are those that are:
|
Available plugins are those that are:
|
||||||
- executable
|
- executable
|
||||||
- begin with "kn-"
|
- begin with "kn-"
|
||||||
- Kn's plugin directory ~/.kn/plugins
|
- Kn's plugin directory ~/.config/kn/plugins
|
||||||
- Anywhere in the execution $PATH (if lookupInPath config variable is enabled)
|
- Anywhere in the execution $PATH (if lookupInPath config variable is enabled)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
@ -22,15 +22,15 @@ kn plugin list [flags]
|
||||||
-h, --help help for list
|
-h, --help help for list
|
||||||
--lookup-plugins look for kn plugins in $PATH
|
--lookup-plugins look for kn plugins in $PATH
|
||||||
--name-only If true, display only the binary name of each plugin, rather than its full path
|
--name-only If true, display only the binary name of each plugin, rather than its full path
|
||||||
--plugins-dir string kn plugins directory (default "~/.kn/plugins")
|
--plugins-dir string kn plugins directory (default "~/.config/kn/plugins")
|
||||||
--verbose verbose output
|
--verbose verbose output
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn revision [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ kn revision delete NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ kn revision describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ kn revision list [name] [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn route [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ kn route describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ kn route list NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn service [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,8 @@ kn service create NAME --image IMAGE [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ kn service delete NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ kn service describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ kn service list [name] [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,8 @@ kn service update NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn source [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn source apiserver [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ kn source apiserver create NAME --resource RESOURCE --service-account ACCOUNTNAM
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ kn source apiserver delete NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ kn source apiserver describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ kn source apiserver list [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ kn source apiserver update NAME --resource RESOURCE --service-account ACCOUNTNAM
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn source binding [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ kn source binding create NAME --subject SCHEDULE --sink SINK --ce-override KEY=V
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ kn source binding delete NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ kn source binding describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ kn source binding list [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ kn source binding update NAME --subject SCHEDULE --sink SINK --ce-override OVERR
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn source cronjob [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ kn source cronjob create NAME --schedule SCHEDULE --sink SINK --data DATA [flags
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ kn source cronjob delete NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ kn source cronjob describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ kn source cronjob list [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ kn source cronjob update NAME --schedule SCHEDULE --sink SERVICE --data DATA [fl
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ kn source list-types [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn trigger [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ kn trigger create NAME --broker BROKER --filter KEY=VALUE --sink SINK [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ kn trigger delete NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ kn trigger describe NAME [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ kn trigger list [name] [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ kn trigger update NAME --filter KEY=VALUE --sink SINK [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ kn version [flags]
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
||||||
```
|
```
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
--log-http log http traffic
|
--log-http log http traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func NewPluginListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
Available plugins are those that are:
|
Available plugins are those that are:
|
||||||
- executable
|
- executable
|
||||||
- begin with "kn-"
|
- begin with "kn-"
|
||||||
- Kn's plugin directory ~/.kn/plugins
|
- Kn's plugin directory ` + commands.Cfg.DefaultPluginDir + `
|
||||||
- Anywhere in the execution $PATH (if lookupInPath config variable is enabled)`,
|
- Anywhere in the execution $PATH (if lookupInPath config variable is enabled)`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return listPlugins(cmd, plFlags)
|
return listPlugins(cmd, plFlags)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ Please refer to the documentation and examples for more information about how wr
|
||||||
|
|
||||||
// AddPluginFlags plugins-dir and lookup-plugins to cmd
|
// AddPluginFlags plugins-dir and lookup-plugins to cmd
|
||||||
func AddPluginFlags(cmd *cobra.Command) {
|
func AddPluginFlags(cmd *cobra.Command) {
|
||||||
cmd.Flags().StringVar(&commands.Cfg.PluginsDir, "plugins-dir", "~/.kn/plugins", "kn plugins directory")
|
cmd.Flags().StringVar(&commands.Cfg.PluginsDir, "plugins-dir", commands.Cfg.DefaultPluginDir, "kn plugins directory")
|
||||||
cmd.Flags().BoolVar(commands.Cfg.LookupPlugins, "lookup-plugins", false, "look for kn plugins in $PATH")
|
cmd.Flags().BoolVar(commands.Cfg.LookupPlugins, "lookup-plugins", false, "look for kn plugins in $PATH")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,6 +49,6 @@ func BindPluginsFlagToViper(cmd *cobra.Command) {
|
||||||
viper.BindPFlag("plugins-dir", cmd.Flags().Lookup("plugins-dir"))
|
viper.BindPFlag("plugins-dir", cmd.Flags().Lookup("plugins-dir"))
|
||||||
viper.BindPFlag("lookup-plugins", cmd.Flags().Lookup("lookup-plugins"))
|
viper.BindPFlag("lookup-plugins", cmd.Flags().Lookup("lookup-plugins"))
|
||||||
|
|
||||||
viper.SetDefault("plugins-dir", "~/.kn/plugins")
|
viper.SetDefault("plugins-dir", commands.Cfg.DefaultPluginDir)
|
||||||
viper.SetDefault("lookup-plugins", false)
|
viper.SetDefault("lookup-plugins", false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ Available Commands:
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for plugin
|
-h, --help help for plugin
|
||||||
--lookup-plugins look for kn plugins in $PATH
|
--lookup-plugins look for kn plugins in $PATH
|
||||||
--plugins-dir string kn plugins directory (default "~/.kn/plugins")
|
--plugins-dir string kn plugins directory (default "~/.config/kn/plugins")
|
||||||
|
|
||||||
Global Flags:
|
Global Flags:
|
||||||
--config string kn config file (default is $HOME/.kn/config.yaml)
|
--config string kn config file (default is $HOME/.config/kn/config.yaml)
|
||||||
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
|
||||||
|
|
||||||
Use "kn plugin [command] --help" for more information about a command.`
|
Use "kn plugin [command] --help" for more information about a command.`
|
||||||
|
|
|
||||||
|
|
@ -177,16 +177,16 @@ Eventing: Manage event subscriptions and channels. Connect up event sources.`,
|
||||||
if params.Output != nil {
|
if params.Output != nil {
|
||||||
rootCmd.SetOutput(params.Output)
|
rootCmd.SetOutput(params.Output)
|
||||||
}
|
}
|
||||||
rootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is $HOME/.kn/config.yaml)")
|
rootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is ~/.config/kn/config.yaml)")
|
||||||
rootCmd.PersistentFlags().StringVar(¶ms.KubeCfgPath, "kubeconfig", "", "kubectl config file (default is $HOME/.kube/config)")
|
rootCmd.PersistentFlags().StringVar(¶ms.KubeCfgPath, "kubeconfig", "", "kubectl config file (default is $HOME/.kube/config)")
|
||||||
|
|
||||||
rootCmd.Flags().StringVar(&Cfg.PluginsDir, "plugins-dir", "~/.kn/plugins", "kn plugins directory")
|
rootCmd.Flags().StringVar(&Cfg.PluginsDir, "plugins-dir", "~/.config/kn/plugins", "kn plugins directory")
|
||||||
rootCmd.Flags().BoolVar(Cfg.LookupPlugins, "lookup-plugins", false, "look for kn plugins in $PATH")
|
rootCmd.Flags().BoolVar(Cfg.LookupPlugins, "lookup-plugins", false, "look for kn plugins in $PATH")
|
||||||
|
|
||||||
viper.BindPFlag("plugins-dir", rootCmd.Flags().Lookup("plugins-dir"))
|
viper.BindPFlag("plugins-dir", rootCmd.Flags().Lookup("plugins-dir"))
|
||||||
viper.BindPFlag("lookup-plugins", rootCmd.Flags().Lookup("lookup-plugins"))
|
viper.BindPFlag("lookup-plugins", rootCmd.Flags().Lookup("lookup-plugins"))
|
||||||
|
|
||||||
viper.SetDefault("plugins-dir", "~/.kn/plugins")
|
viper.SetDefault("plugins-dir", "~/.config/kn/plugins")
|
||||||
viper.SetDefault("lookup-plugins", false)
|
viper.SetDefault("lookup-plugins", false)
|
||||||
|
|
||||||
rootCmd.AddCommand(subCommand)
|
rootCmd.AddCommand(subCommand)
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,19 @@ var CfgFile string
|
||||||
|
|
||||||
// Cfg is Kn's configuration values
|
// Cfg is Kn's configuration values
|
||||||
var Cfg Config = Config{
|
var Cfg Config = Config{
|
||||||
PluginsDir: "",
|
DefaultConfigDir: "~/.config/kn",
|
||||||
LookupPlugins: newBoolP(false),
|
DefaultPluginDir: "~/.config/kn/plugins",
|
||||||
|
PluginsDir: "",
|
||||||
|
LookupPlugins: newBoolP(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config contains the variables for the Kn config
|
// Config contains the variables for the Kn config
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PluginsDir string
|
DefaultConfigDir string
|
||||||
LookupPlugins *bool
|
DefaultPluginDir string
|
||||||
SinkPrefixes []SinkPrefixConfig
|
PluginsDir string
|
||||||
|
LookupPlugins *bool
|
||||||
|
SinkPrefixes []SinkPrefixConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// SinkPrefixConfig is the struct of sink prefix config in kn config
|
// SinkPrefixConfig is the struct of sink prefix config in kn config
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -139,8 +140,9 @@ func NewKnCommand(params ...commands.KnParams) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Persistent flags
|
// Persistent flags
|
||||||
rootCmd.PersistentFlags().StringVar(&commands.CfgFile, "config", "", "kn config file (default is $HOME/.kn/config.yaml)")
|
rootCmd.PersistentFlags().StringVar(&commands.CfgFile, "config", "", "kn config file (default is "+
|
||||||
rootCmd.PersistentFlags().StringVar(&p.KubeCfgPath, "kubeconfig", "", "kubectl config file (default is $HOME/.kube/config)")
|
filepath.Join(commands.Cfg.DefaultConfigDir, "config.yaml")+")")
|
||||||
|
rootCmd.PersistentFlags().StringVar(&p.KubeCfgPath, "kubeconfig", "", "kubectl config file (default is ~/.kube/config)")
|
||||||
flags.AddBothBoolFlags(rootCmd.PersistentFlags(), &p.LogHTTP, "log-http", "", false, "log http traffic")
|
flags.AddBothBoolFlags(rootCmd.PersistentFlags(), &p.LogHTTP, "log-http", "", false, "log http traffic")
|
||||||
|
|
||||||
plugin.AddPluginFlags(rootCmd)
|
plugin.AddPluginFlags(rootCmd)
|
||||||
|
|
@ -208,15 +210,13 @@ func initConfig() {
|
||||||
// Use config file from the flag.
|
// Use config file from the flag.
|
||||||
viper.SetConfigFile(commands.CfgFile)
|
viper.SetConfigFile(commands.CfgFile)
|
||||||
} else {
|
} else {
|
||||||
// Find home directory.
|
configDir, err := defaultConfigDir()
|
||||||
home, err := homedir.Dir()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
// Deprecated path warning message & continue
|
||||||
os.Exit(1)
|
fmt.Fprintf(os.Stderr, "\n%v\n\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search config in home directory with name ".kn" (without extension)
|
// Search config in home directory with name ".kn" (without extension)
|
||||||
viper.AddConfigPath(path.Join(home, ".kn"))
|
viper.AddConfigPath(configDir)
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,6 +229,42 @@ func initConfig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultConfigDir() (string, error) {
|
||||||
|
home, err := homedir.Dir()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
// Check the deprecated path first and fallback to it, add warning to error message
|
||||||
|
if configHome := filepath.Join(home, ".kn"); dirExists(configHome) {
|
||||||
|
migrationPath := filepath.Join(home, ".config", "kn")
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
migrationPath = filepath.Join(os.Getenv("APPDATA"), "kn")
|
||||||
|
}
|
||||||
|
return configHome, fmt.Errorf("WARNING: deprecated kn config directory detected. "+
|
||||||
|
"Please move your configuration to: %s", migrationPath)
|
||||||
|
}
|
||||||
|
// Respect %APPDATA% on MS Windows
|
||||||
|
// C:\Documents and Settings\username\Application Data
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return filepath.Join(os.Getenv("APPDATA"), "kn"), nil
|
||||||
|
}
|
||||||
|
// Respect XDG_CONFIG_HOME if set
|
||||||
|
if xdgHome := os.Getenv("XDG_CONFIG_HOME"); xdgHome != "" {
|
||||||
|
return filepath.Join(xdgHome, "kn"), nil
|
||||||
|
}
|
||||||
|
// Fallback to XDG default for both Linux and macOS
|
||||||
|
// ~/.config/kn
|
||||||
|
return filepath.Join(home, ".config", "kn"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dirExists(path string) bool {
|
||||||
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func initConfigFlags() error {
|
func initConfigFlags() error {
|
||||||
if viper.IsSet("plugins-dir") {
|
if viper.IsSet("plugins-dir") {
|
||||||
commands.Cfg.PluginsDir = viper.GetString("plugins-dir")
|
commands.Cfg.PluginsDir = viper.GetString("plugins-dir")
|
||||||
|
|
@ -253,7 +289,14 @@ func initConfigFlags() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractKnPluginFlags(args []string) (string, bool, error) {
|
func extractKnPluginFlags(args []string) (string, bool, error) {
|
||||||
pluginsDir := "~/.kn/plugins"
|
// Deprecated default path, fallback to it when exist
|
||||||
|
home, _ := homedir.Dir()
|
||||||
|
pluginsDir := filepath.Join(home, ".kn", "plugins")
|
||||||
|
if !dirExists(pluginsDir) {
|
||||||
|
configDir, _ := defaultConfigDir()
|
||||||
|
pluginsDir = filepath.Join(configDir, "plugins")
|
||||||
|
}
|
||||||
|
|
||||||
lookupPluginsInPath := false
|
lookupPluginsInPath := false
|
||||||
|
|
||||||
dirFlag := "--plugins-dir"
|
dirFlag := "--plugins-dir"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue