Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/command/swarm/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func newInitCommand(dockerCli command.Cli) *cobra.Command {
flags.BoolVar(&opts.forceNewCluster, "force-new-cluster", false, "Force create a new cluster from current state")
flags.BoolVar(&opts.autolock, flagAutolock, false, "Enable manager autolocking (requiring an unlock key to start a stopped manager)")
flags.StringVar(&opts.availability, flagAvailability, "active", `Availability of the node ("active"|"pause"|"drain")`)
flags.Var(&opts.rootCACert, flagCACert, "Path to the PEM-formatted root CA certificate to use for the new cluster")
flags.Var(&opts.rootCAKey, flagCAKey, "Path to the PEM-formatted root CA key to use for the new cluster")
addSwarmFlags(flags, &opts.swarmOptions)
return cmd
}
Expand Down
8 changes: 8 additions & 0 deletions cli/command/swarm/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type swarmOptions struct {
maxSnapshots uint64
snapshotInterval uint64
autolock bool
rootCACert PEMFile
rootCAKey PEMFile
}

// NodeAddrOption is a pflag.Value for listening addresses
Expand Down Expand Up @@ -253,6 +255,12 @@ func (opts *swarmOptions) mergeSwarmSpec(spec *swarm.Spec, flags *pflag.FlagSet)
if flags.Changed(flagAutolock) {
spec.EncryptionConfig.AutoLockManagers = opts.autolock
}
if flags.Changed(flagCACert) {
spec.CAConfig.SigningCACert = opts.rootCACert.Contents()
}
if flags.Changed(flagCAKey) {
spec.CAConfig.SigningCAKey = opts.rootCAKey.Contents()
}
}

func (opts *swarmOptions) ToSpec(flags *pflag.FlagSet) swarm.Spec {
Expand Down