mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Record kubectl commands
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)
|
||||
@@ -182,6 +184,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()
|
||||
@@ -472,6 +475,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