From 4324396f617885e9781ddf93d97d329b13d535a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Tue, 10 Aug 2021 10:22:54 +0200 Subject: [PATCH 1/4] 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. --- CHANGELOG.adoc | 16 ++++++++++------ docs/README.md | 4 ++-- docs/cmd/kn_plugin_list.md | 2 +- pkg/kn/commands/plugin/list.go | 2 +- pkg/kn/config/config.go | 11 ++++------- pkg/kn/config/config_test.go | 3 +-- pkg/kn/config/types.go | 13 ++++++------- 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 9690085548..7233fde0fc 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,20 +17,20 @@ |=== | | Description | PR +| ✨ +| Lookup plugins in `$PATH` by default +| https://github.com/knative/client/pull/1412[#1412] + | 🐛 | Show server error messages without any taints | 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] | 🎁 -| Add an `client.knative.dev/updateTimestamp` annotation to trigger a new revision when required -| https://github.com/knative/client/pull/1364[#1364] - -| 🎁 -| Adding darwin/arm64 support to kn +| Adding `darwin/arm64` support to kn | https://github.com/knative/client/pull/1401[#1401] | 🎁 @@ -45,6 +45,10 @@ | make --cmd flag as an array instead of string | 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) diff --git a/docs/README.md b/docs/README.md index 8eaf0bea22..445e7205cd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -77,7 +77,7 @@ The following example contains a fully commented `config.yaml` with all availabl ```yaml # Plugins related configuration 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 # Directory from where plugins are looked up. (default: "$base_dir/plugins" # 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. * `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 diff --git a/docs/cmd/kn_plugin_list.md b/docs/cmd/kn_plugin_list.md index 0108ee1e8d..28b3aa0273 100644 --- a/docs/cmd/kn_plugin_list.md +++ b/docs/cmd/kn_plugin_list.md @@ -10,7 +10,7 @@ Available plugins are those that are: - executable - begin with "kn-" - 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 diff --git a/pkg/kn/commands/plugin/list.go b/pkg/kn/commands/plugin/list.go index a7c38045f1..a97ca5d88b 100644 --- a/pkg/kn/commands/plugin/list.go +++ b/pkg/kn/commands/plugin/list.go @@ -48,7 +48,7 @@ Available plugins are those that are: - executable - begin with "kn-" - 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 { return listPlugins(cmd, plFlags) }, diff --git a/pkg/kn/config/config.go b/pkg/kn/config/config.go index b4e8f5f1ce..2b73695ca5 100644 --- a/pkg/kn/config/config.go +++ b/pkg/kn/config/config.go @@ -71,11 +71,8 @@ func (c *config) PluginsDir() string { // LookupPluginsInPath returns true if plugins should be also checked in the pat func (c *config) LookupPluginsInPath() bool { - if viper.IsSet(keyPluginsLookupInPath) { - return viper.GetBool(keyPluginsLookupInPath) - } else if viper.IsSet(legacyKeyPluginsLookupInPath) { - // Remove that branch if legacy option is switched off - return viper.GetBool(legacyKeyPluginsLookupInPath) + if viper.IsSet(deprecatedKeyPluginsLookupInPath) { + return viper.GetBool(deprecatedKeyPluginsLookupInPath) } else { // If legacy branch is removed, switch to setting the default to viper // See TODO comment below. @@ -117,7 +114,7 @@ func BootstrapConfig() error { if err != nil { return err } - err = viper.BindPFlag(keyPluginsLookupInPath, bootstrapFlagSet.Lookup(flagPluginsLookupInPath)) + err = viper.BindPFlag(deprecatedKeyPluginsLookupInPath, bootstrapFlagSet.Lookup(flagPluginsLookupInPath)) if err != nil { return err } @@ -140,7 +137,7 @@ func BootstrapConfig() error { // TODO: Re-enable when legacy handling for plugin config has been removed // For now default handling is happening directly in the getter of GlobalConfig // viper.SetDefault(keyPluginsDirectory, bootstrapDefaults.pluginsDir) - // viper.SetDefault(keyPluginsLookupInPath, bootstrapDefaults.lookupPluginsInPath) + // viper.SetDefault(deprecatedKeyPluginsLookupInPath, bootstrapDefaults.lookupPluginsInPath) // If a config file is found, read it in. err = viper.ReadInConfig() diff --git a/pkg/kn/config/config_test.go b/pkg/kn/config/config_test.go index e67d488c98..3392393771 100644 --- a/pkg/kn/config/config_test.go +++ b/pkg/kn/config/config_test.go @@ -29,8 +29,7 @@ func TestBootstrapConfig(t *testing.T) { configYaml := ` plugins: directory: /tmp - path-lookup: true - + eventing: sink-mappings: - prefix: service diff --git a/pkg/kn/config/types.go b/pkg/kn/config/types.go index 0253ff7107..b801c58dd5 100644 --- a/pkg/kn/config/types.go +++ b/pkg/kn/config/types.go @@ -70,17 +70,16 @@ type ChannelTypeMapping struct { // config Keys for looking up in viper const ( - keyPluginsDirectory = "plugins.directory" - keyPluginsLookupInPath = "plugins.path-lookup" - keySinkMappings = "eventing.sink-mappings" - keyChannelTypeMappings = "eventing.channel-type-mappings" + keyPluginsDirectory = "plugins.directory" + deprecatedKeyPluginsLookupInPath = "plugins.path-lookup" + keySinkMappings = "eventing.sink-mappings" + keyChannelTypeMappings = "eventing.channel-type-mappings" ) // legacy config keys, deprecated const ( - legacyKeyPluginsDirectory = "plugins-dir" - legacyKeyPluginsLookupInPath = "lookup-plugins" - legacyKeySinkMappings = "sink" + legacyKeyPluginsDirectory = "plugins-dir" + legacyKeySinkMappings = "sink" ) // Global (hidden) flags From 7e3ac396ecf5ef2c099ea5407aa811b281c1d4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Tue, 10 Aug 2021 11:11:08 +0200 Subject: [PATCH 2/4] Review fixes --- CHANGELOG.adoc | 5 +++++ pkg/kn/config/config_test.go | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7233fde0fc..8776fbc517 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,11 @@ |=== | | 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] diff --git a/pkg/kn/config/config_test.go b/pkg/kn/config/config_test.go index 3392393771..c27523b478 100644 --- a/pkg/kn/config/config_test.go +++ b/pkg/kn/config/config_test.go @@ -28,8 +28,7 @@ import ( func TestBootstrapConfig(t *testing.T) { configYaml := ` plugins: - directory: /tmp - + directory: /tmp eventing: sink-mappings: - prefix: service From b50204b7ef7a2385148cb7272ac996ceb0b89c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Tue, 10 Aug 2021 11:27:44 +0200 Subject: [PATCH 3/4] remove trailing whitespace --- pkg/kn/config/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kn/config/config_test.go b/pkg/kn/config/config_test.go index c27523b478..1182435d68 100644 --- a/pkg/kn/config/config_test.go +++ b/pkg/kn/config/config_test.go @@ -28,7 +28,7 @@ import ( func TestBootstrapConfig(t *testing.T) { configYaml := ` plugins: - directory: /tmp + directory: /tmp eventing: sink-mappings: - prefix: service From 4c11afe2df8a6efd5d422d2f15b3bc37beb3898b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Tue, 10 Aug 2021 11:48:23 +0200 Subject: [PATCH 4/4] readd config to make test coverage happy --- pkg/kn/config/config_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/kn/config/config_test.go b/pkg/kn/config/config_test.go index 1182435d68..991d42a391 100644 --- a/pkg/kn/config/config_test.go +++ b/pkg/kn/config/config_test.go @@ -29,6 +29,7 @@ func TestBootstrapConfig(t *testing.T) { configYaml := ` plugins: directory: /tmp + path-lookup: true eventing: sink-mappings: - prefix: service