summaryrefslogtreecommitdiff
path: root/cmd/podman/networks/create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-01 21:43:27 +0100
committerGitHub <noreply@github.com>2020-12-01 21:43:27 +0100
commitb7ff6f09121eee8a0444baede9f6c84cc1f12b71 (patch)
treedcedf6e0674998f3da09a51fe5e48510297ee2c4 /cmd/podman/networks/create.go
parent4b5cb7b1de3caecf0f78f264d5931066851c6a37 (diff)
parent8494bcb866f1c0978cbe35c62c1e3312a91040b4 (diff)
downloadpodman-b7ff6f09121eee8a0444baede9f6c84cc1f12b71.tar.gz
podman-b7ff6f09121eee8a0444baede9f6c84cc1f12b71.tar.bz2
podman-b7ff6f09121eee8a0444baede9f6c84cc1f12b71.zip
Merge pull request #8505 from Luap99/network-labels
podman network label support
Diffstat (limited to 'cmd/podman/networks/create.go')
-rw-r--r--cmd/podman/networks/create.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go
index 17de2c95d..938b8da77 100644
--- a/cmd/podman/networks/create.go
+++ b/cmd/podman/networks/create.go
@@ -6,9 +6,11 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v2/cmd/podman/common"
+ "github.com/containers/podman/v2/cmd/podman/parse"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -27,6 +29,7 @@ var (
var (
networkCreateOptions entities.NetworkCreateOptions
+ labels []string
)
func networkCreateFlags(cmd *cobra.Command) {
@@ -50,6 +53,10 @@ func networkCreateFlags(cmd *cobra.Command) {
flags.StringVar(&networkCreateOptions.MacVLAN, macvlanFlagName, "", "create a Macvlan connection based on this device")
_ = cmd.RegisterFlagCompletionFunc(macvlanFlagName, completion.AutocompleteNone)
+ labelFlagName := "label"
+ flags.StringArrayVar(&labels, labelFlagName, nil, "set metadata on a network")
+ _ = cmd.RegisterFlagCompletionFunc(labelFlagName, completion.AutocompleteNone)
+
// TODO not supported yet
// flags.StringVar(&networkCreateOptions.IPamDriver, "ipam-driver", "", "IP Address Management Driver")
@@ -81,6 +88,11 @@ func networkCreate(cmd *cobra.Command, args []string) error {
}
name = args[0]
}
+ var err error
+ networkCreateOptions.Labels, err = parse.GetAllLabels([]string{}, labels)
+ if err != nil {
+ return errors.Wrap(err, "failed to parse labels")
+ }
response, err := registry.ContainerEngine().NetworkCreate(registry.Context(), name, networkCreateOptions)
if err != nil {
return err