-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from rsteube/add-docker-network
added docker network subcommand
- Loading branch information
Showing
9 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 networkCmd = &cobra.Command{ | ||
Use: "network", | ||
Short: "Manage networks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(networkCmd).Standalone() | ||
|
||
rootCmd.AddCommand(networkCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var network_connectCmd = &cobra.Command{ | ||
Use: "connect", | ||
Short: "Connect a container to a network", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_connectCmd).Standalone() | ||
|
||
network_connectCmd.Flags().String("alias", "", "Add network-scoped alias for the container") | ||
network_connectCmd.Flags().String("driver-opt", "", "driver options for the network") | ||
network_connectCmd.Flags().String("ip", "", "IPv4 address (e.g., 172.30.100.104)") | ||
network_connectCmd.Flags().String("ip6", "", "IPv6 address (e.g., 2001:db8::33)") | ||
network_connectCmd.Flags().String("link", "", "Add link to another container") | ||
network_connectCmd.Flags().String("link-local-ip", "", "Add a link-local address for the container") | ||
networkCmd.AddCommand(network_connectCmd) | ||
|
||
carapace.Gen(network_connectCmd).FlagCompletion(carapace.ActionMap{ | ||
"link": action.ActionContainers(), | ||
}) | ||
|
||
carapace.Gen(network_connectCmd).PositionalCompletion( | ||
action.ActionNetworks(), | ||
action.ActionContainers(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var network_createCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create a network", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_createCmd).Standalone() | ||
|
||
network_createCmd.Flags().Bool("attachable", false, "Enable manual container attachment") | ||
network_createCmd.Flags().String("aux-address", "", "Auxiliary IPv4 or IPv6 addresses used by Network driver (default map[])") | ||
network_createCmd.Flags().String("config-from", "", "The network from which copying the configuration") | ||
network_createCmd.Flags().Bool("config-only", false, "Create a configuration only network") | ||
network_createCmd.Flags().StringP("driver", "d", "", "Driver to manage the Network (default \"bridge\")") | ||
network_createCmd.Flags().String("gateway", "", "IPv4 or IPv6 Gateway for the master subnet") | ||
network_createCmd.Flags().Bool("ingress", false, "Create swarm routing-mesh network") | ||
network_createCmd.Flags().Bool("internal", false, "Restrict external access to the network") | ||
network_createCmd.Flags().String("ip-range", "", "Allocate container ip from a sub-range") | ||
network_createCmd.Flags().String("ipam-driver", "", "IP Address Management Driver (default \"default\")") | ||
network_createCmd.Flags().String("ipam-opt", "", "Set IPAM driver specific options (default map[])") | ||
network_createCmd.Flags().Bool("ipv6", false, "Enable IPv6 networking") | ||
network_createCmd.Flags().String("label", "", "Set metadata on a network") | ||
network_createCmd.Flags().StringP("opt", "o", "", "Set driver specific options (default map[])") | ||
network_createCmd.Flags().String("scope", "", "Control the network's scope") | ||
network_createCmd.Flags().String("subnet", "", "Subnet in CIDR format that represents a network segment") | ||
networkCmd.AddCommand(network_createCmd) | ||
|
||
carapace.Gen(network_createCmd).FlagCompletion(carapace.ActionMap{ | ||
"config-from": action.ActionNetworks(), | ||
"driver": carapace.ActionValues("bridge", "host", "null", "overlay"), | ||
}) | ||
|
||
carapace.Gen(network_createCmd).PositionalCompletion( | ||
action.ActionNetworks(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var network_disconnectCmd = &cobra.Command{ | ||
Use: "disconnect", | ||
Short: "Disconnect a container from a network", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_disconnectCmd).Standalone() | ||
|
||
network_disconnectCmd.Flags().BoolP("force", "f", false, "Force the container to disconnect from a network") | ||
networkCmd.AddCommand(network_disconnectCmd) | ||
|
||
carapace.Gen(network_disconnectCmd).PositionalCompletion( | ||
action.ActionNetworks(), | ||
action.ActionContainers(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var network_inspectCmd = &cobra.Command{ | ||
Use: "inspect", | ||
Short: "Display detailed information on one or more networks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_inspectCmd).Standalone() | ||
|
||
network_inspectCmd.Flags().StringP("format", "f", "", "Format the output using the given Go template") | ||
network_inspectCmd.Flags().BoolP("verbose", "v", false, "Verbose output for diagnostics") | ||
networkCmd.AddCommand(network_inspectCmd) | ||
|
||
carapace.Gen(network_inspectCmd).PositionalAnyCompletion(action.ActionNetworks()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var network_lsCmd = &cobra.Command{ | ||
Use: "ls", | ||
Short: "List networks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_lsCmd).Standalone() | ||
|
||
network_lsCmd.Flags().StringP("filter", "f", "", "Provide filter values (e.g. 'driver=bridge')") | ||
network_lsCmd.Flags().String("format", "", "Pretty-print networks using a Go template") | ||
network_lsCmd.Flags().Bool("no-trunc", false, "Do not truncate the output") | ||
network_lsCmd.Flags().BoolP("quiet", "q", false, "Only display network IDs") | ||
networkCmd.AddCommand(network_lsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 network_pruneCmd = &cobra.Command{ | ||
Use: "prune", | ||
Short: "Remove all unused networks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_pruneCmd).Standalone() | ||
|
||
network_pruneCmd.Flags().String("filter", "", "Provide filter values (e.g. 'until=<timestamp>')") | ||
network_pruneCmd.Flags().BoolP("force", "f", false, "Do not prompt for confirmation") | ||
networkCmd.AddCommand(network_pruneCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var network_rmCmd = &cobra.Command{ | ||
Use: "rm", | ||
Short: "Remove one or more networks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(network_rmCmd).Standalone() | ||
|
||
networkCmd.AddCommand(network_rmCmd) | ||
|
||
carapace.Gen(network_rmCmd).PositionalAnyCompletion(action.ActionNetworks()) | ||
} |