func (o *WhoAmIOptions) Complete(cmd *cobra.Command, args []string) error {
	o.args = args
	config, err := o.configFlags.ToRESTConfig()
	if err != nil {
		return err
	}
	o.tokenRetriever = &tokenRetriever{}
	config.Wrap(func(rt http.RoundTripper) http.RoundTripper {
		o.tokenRetriever.rountTripper = rt
		return o.tokenRetriever
	})
	o.kubeclient, err = kubernetes.NewForConfig(config)
	if err != nil {
		return err
	}
	return nil
}
Complete sets all information required for updating the current context
package cmd
import (
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
	"strings"
	"github.com/rajatjindal/kubectl-whoami/pkg/k8s"
	"github.com/spf13/cobra"
	"k8s.io/cli-runtime/pkg/genericclioptions"
	"k8s.io/client-go/kubernetes"
	_ "k8s.io/client-go/plugin/pkg/client/auth"
)
var Version = "unknown"
type WhoAmIOptions struct {
	configFlags *genericclioptions.ConfigFlags
	iostreams   genericclioptions.IOStreams
	args         []string
	kubeclient   kubernetes.Interface
	printVersion bool
	tokenRetriever *tokenRetriever
}
type tokenRetriever struct {
	rountTripper http.RoundTripper
	token        string
}
func (t *tokenRetriever) RoundTrip(req *http.Request) (*http.Response, error) {
	header := req.Header.Get("authorization")
	switch {
	case strings.HasPrefix(header, "Bearer "):
		t.token = strings.ReplaceAll(header, "Bearer ", "")
	}
	return t.rountTripper.RoundTrip(req)
}
func NewWhoAmIOptions(streams genericclioptions.IOStreams) *WhoAmIOptions {
	return &WhoAmIOptions{
		configFlags: genericclioptions.NewConfigFlags(true),
		iostreams:   streams,
	}
}
func NewCmdWhoAmI(streams genericclioptions.IOStreams) *cobra.Command {
	o := NewWhoAmIOptions(streams)
	cmd := &cobra.Command{
		Use:          "whoami [flags]",
		Short:        "find out the subject for the current context of kubeconfig",
		SilenceUsage: true,
		RunE: func(c *cobra.Command, args []string) error {
			if o.printVersion {
				fmt.Println(Version)
				os.Exit(0)
			}
			if err := o.Complete(c, args); err != nil {
				return err
			}
			if err := o.Validate(); err != nil {
				return err
			}
			if err := o.Run(); err != nil {
				return err
			}
			return nil
		},
	}
	cmd.Flags().BoolVar(&o.printVersion, "version", false, "prints version of plugin")
	o.configFlags.AddFlags(cmd.Flags())
	return cmd
}