Add support for swarm init lock and swarm unlock

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2016-11-09 16:09:00 -08:00
committed by Aaron Lehmann
parent 06666a5a23
commit d006a04357
5 changed files with 84 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
package swarm
import (
"context"
"github.com/spf13/cobra"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/cli"
"github.com/docker/docker/cli/command"
)
func newUnlockCommand(dockerCli *command.DockerCli) *cobra.Command {
cmd := &cobra.Command{
Use: "unlock",
Short: "Unlock swarm",
Args: cli.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
client := dockerCli.Client()
ctx := context.Background()
key, err := readKey(dockerCli.In(), "Please enter unlock key: ")
if err != nil {
return err
}
req := swarm.UnlockRequest{
LockKey: string(key),
}
return client.SwarmUnlock(ctx, req)
},
}
return cmd
}