@@ -33,8 +33,8 @@ func init() {
3333 extraCommands = append (extraCommands , createKubeCommand )
3434 extraHelp = append (extraHelp , `
3535Create a Kubernetes context:
36- $ docker context create kubernetes CONTEXT [flags]
37- (see docker context create kubernetes --help)
36+ $ docker context create k8s CONTEXT [flags]
37+ (see docker context create k8s --help)
3838` )
3939}
4040
@@ -45,18 +45,13 @@ func createKubeCommand() *cobra.Command {
4545 Short : "Create context for a Kubernetes Cluster" ,
4646 Args : cobra .ExactArgs (1 ),
4747 RunE : func (cmd * cobra.Command , args []string ) error {
48- opts .Name = args [0 ]
49-
50- if opts .Endpoint != "" {
51- opts .FromEnvironment = false
52- }
5348 return runCreateKube (cmd .Context (), args [0 ], opts )
5449 },
5550 }
5651
5752 addDescriptionFlag (cmd , & opts .Description )
58- cmd .Flags ().StringVar (& opts .Endpoint , "endpoint " , "" , "The endpoint of the Kubernetes manager" )
59- cmd .Flags ().BoolVar (& opts .FromEnvironment , "from-env" , true , "Get endpoint and creds from env vars" )
53+ cmd .Flags ().StringVar (& opts .KubeconfigPath , "kubeconfig " , "" , "The endpoint of the Kubernetes manager" )
54+ cmd .Flags ().BoolVar (& opts .FromEnvironment , "from-env" , false , "Get endpoint and creds from env vars" )
6055 return cmd
6156}
6257
@@ -65,13 +60,9 @@ func runCreateKube(ctx context.Context, contextName string, opts kube.ContextPar
6560 return errors .Wrapf (errdefs .ErrAlreadyExists , "context %q" , contextName )
6661 }
6762
68- contextData , description := createContextData (opts )
63+ contextData , description , err := opts .CreateContextData ()
64+ if err != nil {
65+ return err
66+ }
6967 return createDockerContext (ctx , contextName , store .KubeContextType , description , contextData )
7068}
71-
72- func createContextData (opts kube.ContextParams ) (interface {}, string ) {
73- return store.KubeContext {
74- Endpoint : opts .Endpoint ,
75- FromEnvironment : opts .FromEnvironment ,
76- }, opts .Description
77- }
0 commit comments