mirror of https://github.com/containers/podman.git
refactor(machine): remove hard code
Use exported variables instead of hard-coded strings. Ref: https://github.com/containers/common/pull/1516 Signed-off-by: Black-Hole1 <bh@bugs.cc>
This commit is contained in:
parent
6633a91c5a
commit
04a1cdfa96
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue