Add --client-certs flag to regeneratecerts command

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F
2018-02-16 14:32:55 -08:00
committed by Joffrey F
parent 97bae3476b
commit 7c1c8d749b
3 changed files with 25 additions and 8 deletions

View File

@@ -314,6 +314,10 @@ var Commands = []cli.Command{
Name: "force, f",
Usage: "Force rebuild and do not prompt",
},
cli.BoolFlag{
Name: "client-certs",
Usage: "Also regenerate client certificates and CA.",
},
},
},
{
@@ -432,14 +436,15 @@ func printIP(h *host.Host) func() error {
func machineCommand(actionName string, host *host.Host, errorChan chan<- error) {
// TODO: These actions should have their own type.
commands := map[string](func() error){
"configureAuth": host.ConfigureAuth,
"start": host.Start,
"stop": host.Stop,
"restart": host.Restart,
"kill": host.Kill,
"upgrade": host.Upgrade,
"ip": printIP(host),
"provision": host.Provision,
"configureAuth": host.ConfigureAuth,
"configureAllAuth": host.ConfigureAllAuth,
"start": host.Start,
"stop": host.Stop,
"restart": host.Restart,
"kill": host.Kill,
"upgrade": host.Upgrade,
"ip": printIP(host),
"provision": host.Provision,
}
log.Debugf("command=%s machine=%s", actionName, host.Name)

View File

@@ -19,5 +19,8 @@ func cmdRegenerateCerts(c CommandLine, api libmachine.API) error {
log.Infof("Regenerating TLS certificates")
if c.Bool("client-certs") {
return runAction("configureAllAuth", c, api)
}
return runAction("configureAuth", c, api)
}

View File

@@ -4,6 +4,7 @@ import (
"regexp"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/cert"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/log"
@@ -267,6 +268,14 @@ func (h *Host) ConfigureAuth() error {
return provisioner.Provision(swarm.Options{}, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions)
}
func (h *Host) ConfigureAllAuth() error {
log.Info("Regenerating local certificates")
if err := cert.BootstrapCertificates(h.AuthOptions()); err != nil {
return err
}
return h.ConfigureAuth()
}
func (h *Host) Provision() error {
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {