mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
use etchosts package from c/common
Use the new logic from c/common to create the hosts file. This will help to better allign the hosts files between buildah and podman. Also this fixes several bugs: - remove host entries when container is stopped and has a netNsCtr - add entries for containers in a pod - do not duplicate entries in the hosts file - use the correct slirp ip when an userns is used Features: - configure host.containers.internal entry in containers.conf - configure base hosts file in containers.conf Fixes #12003 Fixes #13224 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/containers/podman/v4/pkg/namespaces"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -70,30 +69,3 @@ func TestGenerateUserGroupEntry(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, group, "567:x:567:567\n")
|
||||
}
|
||||
|
||||
func TestAppendLocalhost(t *testing.T) {
|
||||
{
|
||||
c := Container{
|
||||
config: &ContainerConfig{
|
||||
ContainerNetworkConfig: ContainerNetworkConfig{
|
||||
NetMode: namespaces.NetworkMode("slirp4netns"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, "127.0.0.1\tlocalhost\n::1\tlocalhost\n", c.appendLocalhost(""))
|
||||
assert.Equal(t, "127.0.0.1\tlocalhost", c.appendLocalhost("127.0.0.1\tlocalhost"))
|
||||
}
|
||||
{
|
||||
c := Container{
|
||||
config: &ContainerConfig{
|
||||
ContainerNetworkConfig: ContainerNetworkConfig{
|
||||
NetMode: namespaces.NetworkMode("host"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, "", c.appendLocalhost(""))
|
||||
assert.Equal(t, "127.0.0.1\tlocalhost", c.appendLocalhost("127.0.0.1\tlocalhost"))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user