Skip to content

Commit 7c1c8d7

Browse files
committed
Add --client-certs flag to regeneratecerts command
Signed-off-by: Joffrey F <[email protected]>
1 parent 97bae34 commit 7c1c8d7

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

commands/commands.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ var Commands = []cli.Command{
314314
Name: "force, f",
315315
Usage: "Force rebuild and do not prompt",
316316
},
317+
cli.BoolFlag{
318+
Name: "client-certs",
319+
Usage: "Also regenerate client certificates and CA.",
320+
},
317321
},
318322
},
319323
{
@@ -432,14 +436,15 @@ func printIP(h *host.Host) func() error {
432436
func machineCommand(actionName string, host *host.Host, errorChan chan<- error) {
433437
// TODO: These actions should have their own type.
434438
commands := map[string](func() error){
435-
"configureAuth": host.ConfigureAuth,
436-
"start": host.Start,
437-
"stop": host.Stop,
438-
"restart": host.Restart,
439-
"kill": host.Kill,
440-
"upgrade": host.Upgrade,
441-
"ip": printIP(host),
442-
"provision": host.Provision,
439+
"configureAuth": host.ConfigureAuth,
440+
"configureAllAuth": host.ConfigureAllAuth,
441+
"start": host.Start,
442+
"stop": host.Stop,
443+
"restart": host.Restart,
444+
"kill": host.Kill,
445+
"upgrade": host.Upgrade,
446+
"ip": printIP(host),
447+
"provision": host.Provision,
443448
}
444449

445450
log.Debugf("command=%s machine=%s", actionName, host.Name)

commands/regeneratecerts.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ func cmdRegenerateCerts(c CommandLine, api libmachine.API) error {
1919

2020
log.Infof("Regenerating TLS certificates")
2121

22+
if c.Bool("client-certs") {
23+
return runAction("configureAllAuth", c, api)
24+
}
2225
return runAction("configureAuth", c, api)
2326
}

libmachine/host/host.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"regexp"
55

66
"github.com/docker/machine/libmachine/auth"
7+
"github.com/docker/machine/libmachine/cert"
78
"github.com/docker/machine/libmachine/drivers"
89
"github.com/docker/machine/libmachine/engine"
910
"github.com/docker/machine/libmachine/log"
@@ -267,6 +268,14 @@ func (h *Host) ConfigureAuth() error {
267268
return provisioner.Provision(swarm.Options{}, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions)
268269
}
269270

271+
func (h *Host) ConfigureAllAuth() error {
272+
log.Info("Regenerating local certificates")
273+
if err := cert.BootstrapCertificates(h.AuthOptions()); err != nil {
274+
return err
275+
}
276+
return h.ConfigureAuth()
277+
}
278+
270279
func (h *Host) Provision() error {
271280
provisioner, err := provision.DetectProvisioner(h.Driver)
272281
if err != nil {

0 commit comments

Comments
 (0)