|
|
@@ -34,22 +34,21 @@ import (
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
cliconfig "github.com/docker/api/cli/config"
|
|
|
- cliopts "github.com/docker/api/cli/options"
|
|
|
"github.com/docker/api/context/store"
|
|
|
)
|
|
|
|
|
|
-func useCommand(opts *cliopts.GlobalOpts) *cobra.Command {
|
|
|
+func useCommand() *cobra.Command {
|
|
|
return &cobra.Command{
|
|
|
Use: "use CONTEXT",
|
|
|
Short: "Set the default context",
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
- return runUse(cmd.Context(), opts.Config, args[0])
|
|
|
+ return runUse(cmd.Context(), args[0])
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func runUse(ctx context.Context, configDir string, name string) error {
|
|
|
+func runUse(ctx context.Context, name string) error {
|
|
|
s := store.ContextStore(ctx)
|
|
|
// Match behavior of existing CLI
|
|
|
if name != store.DefaultContextName {
|
|
|
@@ -57,7 +56,7 @@ func runUse(ctx context.Context, configDir string, name string) error {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
- if err := cliconfig.WriteCurrentContext(configDir, name); err != nil {
|
|
|
+ if err := cliconfig.WriteCurrentContext(cliconfig.Dir(ctx), name); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
fmt.Println(name)
|