Merge pull request #18955 from BlackHole1/remove-hard-code

refactor(machine): remove hard code
This commit is contained in:
OpenShift Merge Robot
2023-06-21 14:53:20 +02:00
committed by GitHub
2 changed files with 6 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containers/common/libnetwork/etchosts"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -618,9 +619,8 @@ func GetProxyVariables() map[string]string {
continue continue
} }
// TODO: use constants for host.containers.internal v := strings.ReplaceAll(value, "127.0.0.1", etchosts.HostContainersInternal)
v := strings.ReplaceAll(value, "127.0.0.1", "host.containers.internal") v = strings.ReplaceAll(v, "localhost", etchosts.HostContainersInternal)
v = strings.ReplaceAll(v, "localhost", "host.containers.internal")
proxyOpts[variable] = v proxyOpts[variable] = v
} }
} }

View File

@ -9,6 +9,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/containers/common/libnetwork/etchosts"
"github.com/containers/podman/v4/pkg/machine" "github.com/containers/podman/v4/pkg/machine"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -55,11 +56,11 @@ func TestPropagateHostEnv(t *testing.T) {
}, },
"http_proxy": { "http_proxy": {
"127.0.0.1:8888", "127.0.0.1:8888",
"host.containers.internal:8888", fmt.Sprintf("%s:8888", etchosts.HostContainersInternal),
}, },
"https_proxy": { "https_proxy": {
"localhost:8888", "localhost:8888",
"host.containers.internal:8888", fmt.Sprintf("%s:8888", etchosts.HostContainersInternal),
}, },
"SSL_CERT_FILE": { "SSL_CERT_FILE": {
"/some/f=oo.cert", "/some/f=oo.cert",