Skip to content

Commit

Permalink
refactor(machine): remove hard code
Browse files Browse the repository at this point in the history
Use exported variables instead of hard-coded strings.

Ref: containers/common#1516

Signed-off-by: Black-Hole1 <[email protected]>
  • Loading branch information
BlackHole1 committed Jun 21, 2023
1 parent 6633a91 commit 04a1cdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/machine/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"strings"

"github.com/containers/common/libnetwork/etchosts"
"github.com/containers/common/pkg/config"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -618,9 +619,8 @@ func GetProxyVariables() map[string]string {
continue
}

// TODO: use constants for host.containers.internal
v := strings.ReplaceAll(value, "127.0.0.1", "host.containers.internal")
v = strings.ReplaceAll(v, "localhost", "host.containers.internal")
v := strings.ReplaceAll(value, "127.0.0.1", etchosts.HostContainersInternal)
v = strings.ReplaceAll(v, "localhost", etchosts.HostContainersInternal)
proxyOpts[variable] = v
}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/machine/qemu/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"testing"

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

0 comments on commit 04a1cdf

Please sign in to comment.