func (v *CommandOverrideVerifier) Verify(path string) []error {
	if v.root == nil {
		return []error{fmt.Errorf("unable to verify path with nil root")}
	}

	// extract the plugin binary name
	segs := strings.Split(path, "/")
	binName := segs[len(segs)-1]

	cmdPath := strings.Split(binName, "-")
	if len(cmdPath) > 1 {
		// the first argument is always "kubectl" for a plugin binary
		cmdPath = cmdPath[1:]
	}

	errors := []error{}

	if isExec, err := isExecutable(path); err == nil && !isExec {
		errors = append(errors, fmt.Errorf("warning: %s identified as a kubectl plugin, but it is not executable", path))
	} else if err != nil {
		errors = append(errors, fmt.Errorf("error: unable to identify %s as an executable file: %v", path, err))
	}

	if existingPath, ok := v.seenPlugins[binName]; ok {
		errors = append(errors, fmt.Errorf("warning: %s is overshadowed by a similarly named plugin: %s", path, existingPath))
	} else {
		v.seenPlugins[binName] = path
	}

	if cmd, _, err := v.root.Find(cmdPath); err == nil {
		errors = append(errors, fmt.Errorf("warning: %s overwrites existing command: %q", binName, cmd.CommandPath()))
	}

	return errors
}
// Verify implements PathVerifier and determines if a given path
// is valid depending on whether or not it overwrites an existing
// kubectl command path, or a previously seen plugin.
Verify implements PathVerifier and determines if a given path
is valid depending on whether or not it overwrites an existing
kubectl command path, or a previously seen plugin.
// Verify implements PathVerifier and determines if a given path // is valid depending on whether or not it overwrites an existing // kubectl command path or a previously seen plugin .
func (v *CommandOverrideVerifier) Verify(path string) []error {
	if v.root == nil {
		return []error{fmt.Errorf("unable to verify path with nil root")}
	}
	segs := strings.Split(path, "/")
	binName := segs[len(segs)-1]
	cmdPath := strings.Split(binName, "-")
	if len(cmdPath) > 1 {
		cmdPath = cmdPath[1:]
	}
	errors := []error{}
	if isExec, err := isExecutable(path); err == nil && !isExec {
		errors = append(errors, fmt.Errorf("warning: %s identified as a kubectl plugin, but it is not executable", path))
	} else if err != nil {
		errors = append(errors, fmt.Errorf("error: unable to identify %s as an executable file: %v", path, err))
	}
	if existingPath, ok := v.seenPlugins[binName]; ok {
		errors = append(errors, fmt.Errorf("warning: %s is overshadowed by a similarly named plugin: %s", path, existingPath))
	} else {
		v.seenPlugins[binName] = path
	}
	if cmd, _, err := v.root.Find(cmdPath); err == nil {
		errors = append(errors, fmt.Errorf("warning: %s overwrites existing command: %q", binName, cmd.CommandPath()))
	}
	return errors
}
func ( v * CommandOverrideVerifier ) Verify ( path string ) [ ] error { if v . root == nil { return [ ] error { fmt . Errorf ( " " ) } } segs := strings . Split ( path , " " ) binName := segs [ len ( segs ) - 1 ] cmdPath := strings . Split ( binName , " " ) if len ( cmdPath ) > 1 { cmdPath = cmdPath [ 1 : ] } errors := [ ] error { } if isExec , err := isExecutable ( path ) ; err == nil && ! isExec { errors = append ( errors , fmt . Errorf ( " " , path ) ) } else if err != nil { errors = append ( errors , fmt . Errorf ( " " , path , err ) ) } if existingPath , ok := v . seenPlugins [ binName ] ; ok { errors = append ( errors , fmt . Errorf ( " " , path , existingPath ) ) } else { v . seenPlugins [ binName ] = path } if cmd , _ , err := v . root . Find ( cmdPath ) ; err == nil { errors = append ( errors , fmt . Errorf ( " " , binName , cmd . CommandPath ( ) ) ) } return errors }
Verify implements PathVerifier and determines if a given path
is valid depending on whether or not it overwrites an existing
kubectl command path, or a previously seen plugin.
Verify implements PathVerifier and determines if a given path is valid depending on whether or not it overwrites an existing kubectl command path or a previously seen plugin .
// extract the plugin binary name // the first argument is always "kubectl" for a plugin binary