Skip to content

Commit

Permalink
Merge pull request containers#6671 from rhatdan/build
Browse files Browse the repository at this point in the history
Fix podman build handling of --http-proxy flag
  • Loading branch information
openshift-merge-robot authored Jun 21, 2020
2 parents bc256d9 + 3556bfe commit 4a1dd9f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
20 changes: 8 additions & 12 deletions cmd/podman/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/containers/buildah/imagebuildah"
buildahCLI "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/pkg/config"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/pkg/domain/entities"
Expand Down Expand Up @@ -396,16 +397,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
runtimeFlags = append(runtimeFlags, "--"+arg)
}

// FIXME: the code below needs to be enabled (and adjusted) once the
// global/root flags are supported.

// conf, err := runtime.GetConfig()
// if err != nil {
// return err
// }
// if conf != nil && conf.Engine.CgroupManager == config.SystemdCgroupsManager {
// runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
// }
containerConfig := registry.PodmanConfig()
if containerConfig.Engine.CgroupManager == config.SystemdCgroupsManager {
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
}

opts := imagebuildah.BuildOptions{
AddCapabilities: flags.CapAdd,
Expand All @@ -418,12 +413,13 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
CNIPluginPath: flags.CNIPlugInPath,
CommonBuildOpts: &buildah.CommonBuildOptions{
AddHost: flags.AddHost,
CgroupParent: flags.CgroupParent,
CPUPeriod: flags.CPUPeriod,
CPUQuota: flags.CPUQuota,
CPUShares: flags.CPUShares,
CPUSetCPUs: flags.CPUSetCPUs,
CPUSetMems: flags.CPUSetMems,
CPUShares: flags.CPUShares,
CgroupParent: flags.CgroupParent,
HTTPProxy: flags.HTTPProxy,
Memory: memoryLimit,
MemorySwap: memorySwap,
ShmSize: flags.ShmSize,
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,21 @@ var _ = Describe("Podman build", func() {
Expect(session.ExitCode()).To(Equal(0))
})

It("podman build --http_proxy flag", func() {
SkipIfRemote()
os.Setenv("http_proxy", "1.2.3.4")
podmanTest.RestoreAllArtifacts()
dockerfile := `FROM docker.io/library/alpine:latest
RUN printenv http_proxy`

dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile")
err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
Expect(err).To(BeNil())
session := podmanTest.PodmanNoCache([]string{"build", "--file", dockerfilePath, podmanTest.TempDir})
session.Wait(120)
Expect(session.ExitCode()).To(Equal(0))
ok, _ := session.GrepString("1.2.3.4")
Expect(ok).To(BeTrue())
os.Unsetenv("http_proxy")
})
})

0 comments on commit 4a1dd9f

Please sign in to comment.