summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders F Björklund <anders.f.bjorklund@gmail.com>2020-11-26 18:05:00 +0100
committerAnders F Björklund <anders.f.bjorklund@gmail.com>2020-12-01 22:33:16 +0100
commitdb70e91bde90514ace510f66a1069207217a8d69 (patch)
tree80f85ad68fdbfbb75c662640ad430a299abd7c07
parentde2b15f4d5a8cd3bf9006d0f3ecdfa75b316f495 (diff)
downloadpodman-db70e91bde90514ace510f66a1069207217a8d69.tar.gz
podman-db70e91bde90514ace510f66a1069207217a8d69.tar.bz2
podman-db70e91bde90514ace510f66a1069207217a8d69.zip
Validate that the bridge option is supported
Thanks Luap99 for the validation suggestion Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
-rw-r--r--libpod/network/create.go26
-rw-r--r--test/e2e/network_create_test.go7
2 files changed, 26 insertions, 7 deletions
diff --git a/libpod/network/create.go b/libpod/network/create.go
index e9ab93262..094fbe349 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -173,14 +173,26 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
ipMasq = false
}
- mtu, err := parseMTU(options.Options["mtu"])
- if err != nil {
- return "", err
- }
+ var mtu int
+ var vlan int
+ for k, v := range options.Options {
+ var err error
+ switch k {
+ case "mtu":
+ mtu, err = parseMTU(v)
+ if err != nil {
+ return "", err
+ }
- vlan, err := parseVlan(options.Options["vlan"])
- if err != nil {
- return "", err
+ case "vlan":
+ vlan, err = parseVlan(v)
+ if err != nil {
+ return "", err
+ }
+
+ default:
+ return "", errors.Errorf("unsupported option %s", k)
+ }
}
// obtain host bridge name
diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go
index 1afd7cec4..21b3074fc 100644
--- a/test/e2e/network_create_test.go
+++ b/test/e2e/network_create_test.go
@@ -355,4 +355,11 @@ var _ = Describe("Podman network create", func() {
Expect(nc.OutputToString()).To(ContainSubstring(`"vlan": 9`))
})
+ It("podman network create with invalid option", func() {
+ net := "invalid-test"
+ nc := podmanTest.Podman([]string{"network", "create", "--opt", "foo=bar", net})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc).To(ExitWithError())
+ })
+
})