(dockerCLI command.Cli)
| 27 | } |
| 28 | |
| 29 | func newCACommand(dockerCLI command.Cli) *cobra.Command { |
| 30 | opts := caOptions{} |
| 31 | |
| 32 | cmd := &cobra.Command{ |
| 33 | Use: "ca [OPTIONS]", |
| 34 | Short: "Display and rotate the root CA", |
| 35 | Args: cli.NoArgs, |
| 36 | RunE: func(cmd *cobra.Command, args []string) error { |
| 37 | return runCA(cmd.Context(), dockerCLI, cmd.Flags(), opts) |
| 38 | }, |
| 39 | Annotations: map[string]string{ |
| 40 | "version": "1.30", |
| 41 | "swarm": "manager", |
| 42 | }, |
| 43 | ValidArgsFunction: cobra.NoFileCompletions, |
| 44 | DisableFlagsInUseLine: true, |
| 45 | } |
| 46 | |
| 47 | flags := cmd.Flags() |
| 48 | addSwarmCAFlags(flags, &opts.swarmCAOptions) |
| 49 | flags.BoolVar(&opts.rotate, flagRotate, false, "Rotate the swarm CA - if no certificate or key are provided, new ones will be generated") |
| 50 | flags.Var(&opts.rootCACert, flagCACert, "Path to the PEM-formatted root CA certificate to use for the new cluster") |
| 51 | flags.Var(&opts.rootCAKey, flagCAKey, "Path to the PEM-formatted root CA key to use for the new cluster") |
| 52 | |
| 53 | flags.BoolVarP(&opts.detach, "detach", "d", false, "Exit immediately instead of waiting for the root rotation to converge") |
| 54 | flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress progress output") |
| 55 | return cmd |
| 56 | } |
| 57 | |
| 58 | func runCA(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts caOptions) error { |
| 59 | apiClient := dockerCLI.Client() |
searching dependent graphs…