environment []string) error { return syscall.Exec(executablePath, cmdArgs, environment) } func handleEndpointExtensions(pluginHandler PluginHandler, cmdArgs []string) error { remainingArgs := []string{} // all "non-flag" arguments for idx := range cmdArgs { if strings.HasPrefix(cmdArgs[idx], "-") { break } remainingArgs = append(remainingArgs, strings.Replace(cmdArgs[idx], "-", "_", -1)) } foundBinaryPath := "" for len(remainingArgs) > 0 { path, err := pluginHandler.Lookup(fmt.Sprintf("kubectl-%s", strings.Join(remainingArgs, "-"))) // snip. foundBinaryPath = path break } // snip. if err := pluginHandler.Execute(foundBinaryPath, append([]string{foundBinaryPath}, cmdArgs[len(remainingArgs):]...), os.Environ()); err != nil { return err } return nil } ࣮ૉ https://github.com/kubernetes/kubernetes/blob/v1.12.2/pkg/kubectl/cmd/cmd.go