(dockerCLI command.Cli)
| 42 | } |
| 43 | |
| 44 | func newCreateCommand(dockerCLI command.Cli) *cobra.Command { |
| 45 | opts := createOptions{} |
| 46 | cmd := &cobra.Command{ |
| 47 | Use: "create [OPTIONS] CONTEXT", |
| 48 | Short: "Create a context", |
| 49 | Args: cli.ExactArgs(1), |
| 50 | RunE: func(cmd *cobra.Command, args []string) error { |
| 51 | return runCreate(dockerCLI, args[0], opts) |
| 52 | }, |
| 53 | Long: longCreateDescription(), |
| 54 | ValidArgsFunction: cobra.NoFileCompletions, |
| 55 | DisableFlagsInUseLine: true, |
| 56 | } |
| 57 | flags := cmd.Flags() |
| 58 | flags.StringVar(&opts.description, "description", "", "Description of the context") |
| 59 | flags.StringToStringVar(&opts.endpoint, "docker", nil, "set the docker endpoint") |
| 60 | flags.StringVar(&opts.from, "from", "", "create context from a named context") |
| 61 | return cmd |
| 62 | } |
| 63 | |
| 64 | // runCreate creates a Docker context |
| 65 | func runCreate(dockerCLI command.Cli, name string, opts createOptions) error { |
no test coverage detected
searching dependent graphs…