Skip to content

Commit da6f164

Browse files
vyasgunrhuss
andauthored
Remove lookup-plugins flag (#1506)
Co-authored-by: Roland Huß <roland@ro14nd.de>
1 parent c1e3589 commit da6f164

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

cmd/kn/main_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@ func TestStripFlags(t *testing.T) {
203203
[]string{"test", "second"},
204204
"",
205205
},
206-
{
207-
[]string{"--lookup-plugins", "bla", "test", "second"},
208-
[]string{"bla", "test", "second"},
209-
"",
210-
},
211206
{
212207
[]string{"--config-file", "bla", "test", "second"},
213208
[]string{"test", "second"},

pkg/kn/config/config.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,7 @@ func (c *config) PluginsDir() string {
8888

8989
// LookupPluginsInPath returns true if plugins should be also checked in the pat
9090
func (c *config) LookupPluginsInPath() bool {
91-
if viper.IsSet(deprecatedKeyPluginsLookupInPath) {
92-
return viper.GetBool(deprecatedKeyPluginsLookupInPath)
93-
} else {
94-
// If legacy branch is removed, switch to setting the default to viper
95-
// See TODO comment below.
96-
return bootstrapDefaults.lookupPluginsInPath
97-
}
91+
return bootstrapDefaults.lookupPluginsInPath
9892
}
9993

10094
func (c *config) SinkMappings() []SinkMapping {
@@ -131,10 +125,6 @@ func BootstrapConfig() error {
131125
if err != nil {
132126
return err
133127
}
134-
err = viper.BindPFlag(deprecatedKeyPluginsLookupInPath, bootstrapFlagSet.Lookup(flagPluginsLookupInPath))
135-
if err != nil {
136-
return err
137-
}
138128

139129
viper.SetConfigFile(GlobalConfig.ConfigFile())
140130
configFile := GlobalConfig.ConfigFile()
@@ -159,7 +149,6 @@ func BootstrapConfig() error {
159149
// TODO: Re-enable when legacy handling for plugin config has been removed
160150
// For now default handling is happening directly in the getter of GlobalConfig
161151
// viper.SetDefault(keyPluginsDirectory, bootstrapDefaults.pluginsDir)
162-
// viper.SetDefault(deprecatedKeyPluginsLookupInPath, bootstrapDefaults.lookupPluginsInPath)
163152

164153
// If a config file is found, read it in.
165154
err = viper.ReadInConfig()
@@ -182,10 +171,8 @@ func BootstrapConfig() error {
182171
func AddBootstrapFlags(flags *flag.FlagSet) {
183172
flags.StringVar(&globalConfig.configFile, "config", "", fmt.Sprintf("kn configuration file (default: %s)", defaultConfigFileForUsageMessage()))
184173
flags.String(flagPluginsDir, "", "Directory holding kn plugins")
185-
flags.Bool(flagPluginsLookupInPath, false, "Search kn plugins also in $PATH")
186174

187175
// Let's try that and mark the flags as hidden: (as those configuration is a permanent choice of operation)
188-
flags.MarkHidden(flagPluginsLookupInPath)
189176
flags.MarkHidden(flagPluginsDir)
190177
}
191178

pkg/kn/config/types.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ type ChannelTypeMapping struct {
7070

7171
// config Keys for looking up in viper
7272
const (
73-
keyPluginsDirectory = "plugins.directory"
74-
deprecatedKeyPluginsLookupInPath = "plugins.path-lookup"
75-
keySinkMappings = "eventing.sink-mappings"
76-
keyChannelTypeMappings = "eventing.channel-type-mappings"
73+
keyPluginsDirectory = "plugins.directory"
74+
keySinkMappings = "eventing.sink-mappings"
75+
keyChannelTypeMappings = "eventing.channel-type-mappings"
7776
)
7877

7978
// legacy config keys, deprecated
@@ -85,6 +84,5 @@ const (
8584
// Global (hidden) flags
8685
// TODO: Remove me if decided that they are not needed
8786
const (
88-
flagPluginsDir = "plugins-dir"
89-
flagPluginsLookupInPath = "lookup-plugins"
87+
flagPluginsDir = "plugins-dir"
9088
)

test/e2e/plugins_test.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,13 @@ func TestPluginWithoutLookup(t *testing.T) {
122122
r := test.NewKnRunResultCollector(t, it)
123123
defer r.DumpIfFailed()
124124

125-
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=false"}
125+
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir)}
126126

127127
t.Log("list plugin in --plugins-dir")
128128
listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{})
129129

130130
t.Log("execute plugin in --plugins-dir")
131131
runPlugin(r, knFlags, "helloe2e", []string{"e2e", "test"}, []string{"Hello Knative, I'm a Kn plugin", "I received arguments", "e2e"})
132-
133-
t.Log("does not list any other plugin in $PATH")
134-
listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{pc.knPluginPath2})
135132
}
136133

137134
func TestPluginInHelpMessage(t *testing.T) {
@@ -159,7 +156,7 @@ func TestPluginWithLookup(t *testing.T) {
159156
assert.NilError(t, pc.setup())
160157
defer pc.teardown()
161158

162-
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=true"}
159+
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir)}
163160

164161
t.Log("list plugin in --plugins-dir")
165162
listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{pc.knPluginPath2})
@@ -178,7 +175,7 @@ func TestListPluginInPath(t *testing.T) {
178175
defer tearDownWithPath(pc, oldPath)
179176

180177
t.Log("list plugin in $PATH")
181-
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=true"}
178+
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir)}
182179
listPlugin(r, knFlags, []string{pc.knPluginPath, pc.knPluginPath2}, []string{})
183180

184181
r.DumpIfFailed()
@@ -195,7 +192,7 @@ func TestExecutePluginInPath(t *testing.T) {
195192
defer tearDownWithPath(pc, oldPath)
196193

197194
t.Log("execute plugin in $PATH")
198-
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=true"}
195+
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir)}
199196
runPlugin(r, knFlags, "hello2e2e", []string{}, []string{"Hello Knative, I'm a Kn plugin"})
200197
}
201198

@@ -218,11 +215,6 @@ func TestExecutePluginInPathWithError(t *testing.T) {
218215
assert.NilError(t, err)
219216
assert.NilError(t, os.Setenv("PATH", fmt.Sprintf("%s%s%s", oldPath, delim, pluginsDir)))
220217
defer tearDownWithPath(pc, oldPath)
221-
222-
out := test.Kn{}.Run("--lookup-plugins=true", "hello3e2e")
223-
r.AssertError(out)
224-
assert.Check(r.T(), util.ContainsAll(out.Stderr, "Error: exit status 1"))
225-
assert.Check(r.T(), util.ContainsNone(out.Stderr, "Run", "kn --help", "usage"))
226218
}
227219

228220
// Private

0 commit comments

Comments
 (0)