Merge pull request #17175 from Luap99/default-invalid-netname

network create: do not allow `default` as name
This commit is contained in:
OpenShift Merge Robot
2023-01-20 11:18:01 -05:00
committed by GitHub
2 changed files with 2 additions and 2 deletions

View File

@ -151,7 +151,7 @@ func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, o
func (ic *ContainerEngine) NetworkCreate(ctx context.Context, network types.Network, createOptions *types.NetworkCreateOptions) (*types.Network, error) { func (ic *ContainerEngine) NetworkCreate(ctx context.Context, network types.Network, createOptions *types.NetworkCreateOptions) (*types.Network, error) {
// TODO (5.0): Stop accepting "pasta" as value here // TODO (5.0): Stop accepting "pasta" as value here
if util.StringInSlice(network.Name, []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns"}) { if util.StringInSlice(network.Name, []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns", "default"}) {
return nil, fmt.Errorf("cannot create network with name %q because it conflicts with a valid network mode", network.Name) return nil, fmt.Errorf("cannot create network with name %q because it conflicts with a valid network mode", network.Name)
} }
network, err := ic.Libpod.Network().NetworkCreate(network, createOptions) network, err := ic.Libpod.Network().NetworkCreate(network, createOptions)

View File

@ -366,7 +366,7 @@ var _ = Describe("Podman network create", func() {
}) })
It("podman network create with invalid name", func() { It("podman network create with invalid name", func() {
for _, name := range []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns"} { for _, name := range []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns", "default"} {
nc := podmanTest.Podman([]string{"network", "create", name}) nc := podmanTest.Podman([]string{"network", "create", name})
nc.WaitWithDefaultTimeout() nc.WaitWithDefaultTimeout()
Expect(nc).To(Exit(125)) Expect(nc).To(Exit(125))