Deprecate `lookup-path` option and updated relevant documentation (#1422)

* Deprecate `lookup-path` option and updated relevant documentation

Lookup in path is now the default for all plugins.
This option will be removed eventually in a future version,
when path lookup is enabled uncoditinally and can't be turned of.

* Review fixes

* remove trailing whitespace

* readd config to make test coverage happy
This commit is contained in:
Roland Huß 2021-08-10 12:54:12 +02:00 committed by GitHub
parent f8a8284915
commit 4691210013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 25 deletions

View File

@ -17,20 +17,25 @@
|=== |===
| | Description | PR | | Description | PR
| ✨
| Deprecate `lookup-path` as path lookup will always be enabled in the future
| https://github.com/knative/client/pull/1422[#1422]
| ✨
| Lookup plugins in `$PATH` by default
| https://github.com/knative/client/pull/1412[#1412]
| 🐛 | 🐛
| Show server error messages without any taints | Show server error messages without any taints
| https://github.com/knative/client/pull/1406[#1406] | https://github.com/knative/client/pull/1406[#1406]
| 🎁 | 🎁
| Adding --class flag to broker create command | Adding `--class` flag to broker create command
| https://github.com/knative/client/pull/1402[#1402] | https://github.com/knative/client/pull/1402[#1402]
| 🎁 | 🎁
| Add an `client.knative.dev/updateTimestamp` annotation to trigger a new revision when required | Adding `darwin/arm64` support to kn
| https://github.com/knative/client/pull/1364[#1364]
| 🎁
| Adding darwin/arm64 support to kn
| https://github.com/knative/client/pull/1401[#1401] | https://github.com/knative/client/pull/1401[#1401]
| 🎁 | 🎁
@ -45,6 +50,10 @@
| make --cmd flag as an array instead of string | make --cmd flag as an array instead of string
| https://github.com/knative/client/pull/1380[#1380] | https://github.com/knative/client/pull/1380[#1380]
| 🎁
| Add an `client.knative.dev/updateTimestamp` annotation to trigger a new revision when required
| https://github.com/knative/client/pull/1364[#1364]
|=== |===
## v0.24.0 (2021-06-29) ## v0.24.0 (2021-06-29)

View File

@ -77,7 +77,7 @@ The following example contains a fully commented `config.yaml` with all availabl
```yaml ```yaml
# Plugins related configuration # Plugins related configuration
plugins: plugins:
# Whether to lookup configuration in the execution path (default: false) # Whether to lookup configuration in the execution path (default: true). This option is deprecated and will be removed in a future version where path lookup will be enabled unconditionally
path-lookup: true path-lookup: true
# Directory from where plugins are looked up. (default: "$base_dir/plugins" # Directory from where plugins are looked up. (default: "$base_dir/plugins"
# where "$base_dir" is the directory where this configuration file is stored) # where "$base_dir" is the directory where this configuration file is stored)
@ -118,7 +118,7 @@ You can specify the following options:
plugins. It can be any directory that is visible to the user. plugins. It can be any directory that is visible to the user.
* `path-lookup`, which is the same as the persistent flag * `path-lookup`, which is the same as the persistent flag
`--lookup-plugins-in-path` and specifies if `kn` should look for plugins anywhere in the specified `PATH` environment variable. This option is a boolean type, and the default value is `false`. `--lookup-plugins-in-path` and specifies if `kn` should look for plugins anywhere in the specified `PATH` environment variable. This option is a boolean type, and the default value is `true`. This option is DEPRECATED and will be removed in a future version, when path lookup will be always enabled.
#### Eventing configuration #### Eventing configuration

View File

@ -10,7 +10,7 @@ Available plugins are those that are:
- executable - executable
- begin with "kn-" - begin with "kn-"
- Kn's plugin directory - Kn's plugin directory
- Anywhere in the execution $PATH (if plugins.path-lookup configuration variable is enabled) - Anywhere in the execution $PATH
``` ```
kn plugin list kn plugin list

View File

@ -48,7 +48,7 @@ Available plugins are those that are:
- executable - executable
- begin with "kn-" - begin with "kn-"
- Kn's plugin directory - Kn's plugin directory
- Anywhere in the execution $PATH (if plugins.path-lookup configuration variable is enabled)`, - Anywhere in the execution $PATH`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return listPlugins(cmd, plFlags) return listPlugins(cmd, plFlags)
}, },

View File

@ -71,11 +71,8 @@ func (c *config) PluginsDir() string {
// LookupPluginsInPath returns true if plugins should be also checked in the pat // LookupPluginsInPath returns true if plugins should be also checked in the pat
func (c *config) LookupPluginsInPath() bool { func (c *config) LookupPluginsInPath() bool {
if viper.IsSet(keyPluginsLookupInPath) { if viper.IsSet(deprecatedKeyPluginsLookupInPath) {
return viper.GetBool(keyPluginsLookupInPath) return viper.GetBool(deprecatedKeyPluginsLookupInPath)
} else if viper.IsSet(legacyKeyPluginsLookupInPath) {
// Remove that branch if legacy option is switched off
return viper.GetBool(legacyKeyPluginsLookupInPath)
} else { } else {
// If legacy branch is removed, switch to setting the default to viper // If legacy branch is removed, switch to setting the default to viper
// See TODO comment below. // See TODO comment below.
@ -117,7 +114,7 @@ func BootstrapConfig() error {
if err != nil { if err != nil {
return err return err
} }
err = viper.BindPFlag(keyPluginsLookupInPath, bootstrapFlagSet.Lookup(flagPluginsLookupInPath)) err = viper.BindPFlag(deprecatedKeyPluginsLookupInPath, bootstrapFlagSet.Lookup(flagPluginsLookupInPath))
if err != nil { if err != nil {
return err return err
} }
@ -140,7 +137,7 @@ func BootstrapConfig() error {
// TODO: Re-enable when legacy handling for plugin config has been removed // TODO: Re-enable when legacy handling for plugin config has been removed
// For now default handling is happening directly in the getter of GlobalConfig // For now default handling is happening directly in the getter of GlobalConfig
// viper.SetDefault(keyPluginsDirectory, bootstrapDefaults.pluginsDir) // viper.SetDefault(keyPluginsDirectory, bootstrapDefaults.pluginsDir)
// viper.SetDefault(keyPluginsLookupInPath, bootstrapDefaults.lookupPluginsInPath) // viper.SetDefault(deprecatedKeyPluginsLookupInPath, bootstrapDefaults.lookupPluginsInPath)
// If a config file is found, read it in. // If a config file is found, read it in.
err = viper.ReadInConfig() err = viper.ReadInConfig()

View File

@ -30,7 +30,6 @@ func TestBootstrapConfig(t *testing.T) {
plugins: plugins:
directory: /tmp directory: /tmp
path-lookup: true path-lookup: true
eventing: eventing:
sink-mappings: sink-mappings:
- prefix: service - prefix: service

View File

@ -71,7 +71,7 @@ type ChannelTypeMapping struct {
// config Keys for looking up in viper // config Keys for looking up in viper
const ( const (
keyPluginsDirectory = "plugins.directory" keyPluginsDirectory = "plugins.directory"
keyPluginsLookupInPath = "plugins.path-lookup" deprecatedKeyPluginsLookupInPath = "plugins.path-lookup"
keySinkMappings = "eventing.sink-mappings" keySinkMappings = "eventing.sink-mappings"
keyChannelTypeMappings = "eventing.channel-type-mappings" keyChannelTypeMappings = "eventing.channel-type-mappings"
) )
@ -79,7 +79,6 @@ const (
// legacy config keys, deprecated // legacy config keys, deprecated
const ( const (
legacyKeyPluginsDirectory = "plugins-dir" legacyKeyPluginsDirectory = "plugins-dir"
legacyKeyPluginsLookupInPath = "lookup-plugins"
legacyKeySinkMappings = "sink" legacyKeySinkMappings = "sink"
) )