Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes remaining references to 'lookup-plugins-in-path' #481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/kn/commands/plugin/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestPluginHandler(t *testing.T) {
})

t.Run("when plugin is in $PATH", func(t *testing.T) {
t.Run("--lookup-plugins-in-path=true", func(t *testing.T) {
t.Run("--lookup-plugins=true", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it that we now have --lookup-plugins and --no-lookup-plugins for boolean params ?

setup(t)
defer cleanup(t)

Expand All @@ -106,7 +106,7 @@ func TestPluginHandler(t *testing.T) {
assert.Assert(t, exists == true, fmt.Sprintf("could not Lookup(%s)", pluginName))
})

t.Run("--lookup-plugins-in-path=false", func(t *testing.T) {
t.Run("--lookup-plugins=false", func(t *testing.T) {
setup(t)
defer cleanup(t)

Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Please refer to the documentation and examples for more information about how wr
return pluginCmd
}

// AddPluginFlags plugins-dir and lookup-plugins-in-path to cmd
// AddPluginFlags plugins-dir and lookup-plugins to cmd
func AddPluginFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&commands.Cfg.PluginsDir, "plugins-dir", "~/.kn/plugins", "kn plugins directory")
cmd.Flags().BoolVar(&commands.Cfg.LookupPlugins, "lookup-plugins", false, "look for kn plugins in $PATH")
Expand Down
12 changes: 6 additions & 6 deletions pkg/kn/core/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
func NewDefaultKnCommand() *cobra.Command {
rootCmd := NewKnCommand()

// Needed since otherwise --plugins-dir and --lookup-plugins-in-path
// Needed since otherwise --plugins-dir and --lookup-plugins
// will not be accounted for since the plugin is not a Cobra command
// and will not be parsed
pluginsDir, lookupPluginsInPath, err := extractKnPluginFlags(os.Args)
Expand Down Expand Up @@ -218,7 +218,7 @@ func extractKnPluginFlags(args []string) (string, bool, error) {
lookupPluginsInPath := false

dirFlag := "--plugins-dir"
pathFlag := "--lookup-plugins-in-path"
pathFlag := "--lookup-plugins"
var err error

for _, arg := range args {
Expand All @@ -235,10 +235,10 @@ func extractKnPluginFlags(args []string) (string, bool, error) {
}

if arg == pathFlag {
// just --lookup-plugins-in-path no "="
// just --lookup-plugins no "="
lookupPluginsInPath = true
} else if strings.HasPrefix(arg, pathFlag+"=") {
// Starts with --lookup-plugins-in-path= so we parse value
// Starts with --lookup-plugins= so we parse value
arg = arg[len(pathFlag)+1:]
if lookupPluginsInPath, err = strconv.ParseBool(arg); err != nil {
return "", false, fmt.Errorf("Invalid boolean value(%q) for %s flag", arg, dirFlag)
Expand All @@ -257,8 +257,8 @@ func removeKnPluginFlags(args []string) []string {
for _, arg := range args {
if arg == "--plugins-dir" ||
strings.HasPrefix(arg, "--plugins-dir=") ||
arg == "--lookup-plugins-in-path" ||
strings.HasPrefix(arg, "--plookup-plugins-in-path=") {
arg == "--lookup-plugins" ||
strings.HasPrefix(arg, "--lookup-plugins=") {
continue
} else {
remainingArgs = append(remainingArgs, arg)
Expand Down