Skip to content

Commit

Permalink
removes remaining references to 'lookup-plugins-in-path' (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilien authored and knative-prow-robot committed Nov 11, 2019
1 parent ad02647 commit 1f27eca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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) {
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

0 comments on commit 1f27eca

Please sign in to comment.