mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 16:06:51 +00:00
Merge pull request #20035 from janetkuo/record-command
Auto commit by PR queue bot
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
"os/user"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/emicklei/go-restful/swagger"
|
||||
@@ -62,6 +63,7 @@ const (
|
||||
type Factory struct {
|
||||
clients *ClientCache
|
||||
flags *pflag.FlagSet
|
||||
cmd string
|
||||
|
||||
// Returns interfaces for dealing with arbitrary runtime.Objects.
|
||||
Object func() (meta.RESTMapper, runtime.ObjectTyper)
|
||||
@@ -184,6 +186,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
||||
return &Factory{
|
||||
clients: clients,
|
||||
flags: flags,
|
||||
cmd: recordCommand(os.Args),
|
||||
|
||||
Object: func() (meta.RESTMapper, runtime.ObjectTyper) {
|
||||
cfg, err := clientConfig.ClientConfig()
|
||||
@@ -482,6 +485,17 @@ func GetFirstPod(client *client.Client, namespace string, selector map[string]st
|
||||
return pod, nil
|
||||
}
|
||||
|
||||
func recordCommand(args []string) string {
|
||||
if len(args) > 0 {
|
||||
args[0] = "kubectl"
|
||||
}
|
||||
return strings.Join(args, " ")
|
||||
}
|
||||
|
||||
func (f *Factory) Command() string {
|
||||
return f.cmd
|
||||
}
|
||||
|
||||
// BindFlags adds any flags that are common to all kubectl sub commands.
|
||||
func (f *Factory) BindFlags(flags *pflag.FlagSet) {
|
||||
// any flags defined by external projects (not part of pflags)
|
||||
|
||||
Reference in New Issue
Block a user