Skip to content

Commit

Permalink
Merge pull request #116 from rsteube/add-docker-swarm
Browse files Browse the repository at this point in the history
added docker swarm subcommand
  • Loading branch information
rsteube authored Sep 6, 2020
2 parents 54fc3f8 + 0e5d6f3 commit 6c8d54c
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 0 deletions.
18 changes: 18 additions & 0 deletions completers/docker_completer/cmd/swarm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarmCmd = &cobra.Command{
Use: "swarm",
Short: "Manage Swarm",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarmCmd).Standalone()

rootCmd.AddCommand(swarmCmd)
}
30 changes: 30 additions & 0 deletions completers/docker_completer/cmd/swarm_ca.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_caCmd = &cobra.Command{
Use: "ca",
Short: "Display and rotate the root CA",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_caCmd).Standalone()

swarm_caCmd.Flags().String("ca-cert", "", "Path to the PEM-formatted root CA certificate to use for the")
swarm_caCmd.Flags().String("ca-key", "", "Path to the PEM-formatted root CA key to use for the new cluster")
swarm_caCmd.Flags().String("cert-expiry", "", "Validity period for node certificates (ns|us|ms|s|m|h)")
swarm_caCmd.Flags().BoolP("detach", "d", false, "Exit immediately instead of waiting for the root rotation to")
swarm_caCmd.Flags().String("external-ca", "", "Specifications of one or more certificate signing endpoints")
swarm_caCmd.Flags().BoolP("quiet", "q", false, "Suppress progress output")
swarm_caCmd.Flags().Bool("rotate", false, "Rotate the swarm CA - if no certificate or key are provided,")
swarmCmd.AddCommand(swarm_caCmd)

carapace.Gen(swarm_caCmd).FlagCompletion(carapace.ActionMap{
"ca-cert": carapace.ActionFiles(".crt"),
"ca-key": carapace.ActionFiles(".key"),
})
}
37 changes: 37 additions & 0 deletions completers/docker_completer/cmd/swarm_init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_initCmd = &cobra.Command{
Use: "init",
Short: "Initialize a swarm",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_initCmd).Standalone()

swarm_initCmd.Flags().String("advertise-addr", "", "Advertised address (format: <ip|interface>[:port])")
swarm_initCmd.Flags().Bool("autolock", false, "Enable manager autolocking (requiring an unlock")
swarm_initCmd.Flags().String("availability", "", "Availability of the node")
swarm_initCmd.Flags().String("cert-expiry", "", "Validity period for node certificates")
swarm_initCmd.Flags().String("data-path-addr", "", "Address or interface to use for data path")
swarm_initCmd.Flags().String("data-path-port", "", "Port number to use for data path traffic (1024 -")
swarm_initCmd.Flags().String("default-addr-pool", "", "default address pool in CIDR format (default [])")
swarm_initCmd.Flags().String("default-addr-pool-mask-length", "", "default address pool subnet mask length (default 24)")
swarm_initCmd.Flags().String("dispatcher-heartbeat", "", "Dispatcher heartbeat period (ns|us|ms|s|m|h)")
swarm_initCmd.Flags().String("external-ca", "", "Specifications of one or more certificate")
swarm_initCmd.Flags().Bool("force-new-cluster", false, "Force create a new cluster from current state")
swarm_initCmd.Flags().String("listen-addr", "", "Listen address (format: <ip|interface>[:port])")
swarm_initCmd.Flags().String("max-snapshots", "", "Number of additional Raft snapshots to retain")
swarm_initCmd.Flags().String("snapshot-interval", "", "Number of log entries between Raft snapshots")
swarm_initCmd.Flags().String("task-history-limit", "", "Task history retention limit (default 5)")
swarmCmd.AddCommand(swarm_initCmd)

carapace.Gen(swarm_initCmd).FlagCompletion(carapace.ActionMap{
"availability": carapace.ActionValues("active", "pause", "drain"),
})
}
24 changes: 24 additions & 0 deletions completers/docker_completer/cmd/swarm_join.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_jointokenCmd = &cobra.Command{
Use: "join-token",
Short: "Manage join tokens",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_jointokenCmd).Standalone()

swarm_jointokenCmd.Flags().BoolP("quiet", "q", false, "Only display token")
swarm_jointokenCmd.Flags().Bool("rotate", false, "Rotate join token")
swarmCmd.AddCommand(swarm_jointokenCmd)

carapace.Gen(swarm_jointokenCmd).PositionalCompletion(
carapace.ActionValues("worker", "manager"),
)
}
19 changes: 19 additions & 0 deletions completers/docker_completer/cmd/swarm_leave.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_leaveCmd = &cobra.Command{
Use: "leave",
Short: "Leave the swarm",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_leaveCmd).Standalone()

swarm_leaveCmd.Flags().BoolP("force", "f", false, "Force this node to leave the swarm, ignoring warnings")
swarmCmd.AddCommand(swarm_leaveCmd)
}
18 changes: 18 additions & 0 deletions completers/docker_completer/cmd/swarm_unlock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_unlockCmd = &cobra.Command{
Use: "unlock",
Short: "Unlock swarm",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_unlockCmd).Standalone()

swarmCmd.AddCommand(swarm_unlockCmd)
}
20 changes: 20 additions & 0 deletions completers/docker_completer/cmd/swarm_unlockkey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_unlockkeyCmd = &cobra.Command{
Use: "unlock-key",
Short: "Manage the unlock key",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_unlockkeyCmd).Standalone()

swarm_unlockkeyCmd.Flags().BoolP("quiet", "q", false, "Only display token")
swarm_unlockkeyCmd.Flags().Bool("rotate", false, "Rotate unlock key")
swarmCmd.AddCommand(swarm_unlockkeyCmd)
}
25 changes: 25 additions & 0 deletions completers/docker_completer/cmd/swarm_update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var swarm_updateCmd = &cobra.Command{
Use: "update",
Short: "Update the swarm",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(swarm_updateCmd).Standalone()

swarm_updateCmd.Flags().Bool("autolock", false, "Change manager autolocking setting (true|false)")
swarm_updateCmd.Flags().String("cert-expiry", "", "Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)")
swarm_updateCmd.Flags().String("dispatcher-heartbeat", "", "Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)")
swarm_updateCmd.Flags().String("external-ca", "", "Specifications of one or more certificate signing endpoints")
swarm_updateCmd.Flags().String("max-snapshots", "", "Number of additional Raft snapshots to retain")
swarm_updateCmd.Flags().String("snapshot-interval", "", "Number of log entries between Raft snapshots (default 10000)")
swarm_updateCmd.Flags().String("task-history-limit", "", "Task history retention limit (default 5)")
swarmCmd.AddCommand(swarm_updateCmd)
}

0 comments on commit 6c8d54c

Please sign in to comment.