mirror of
https://github.com/containers/podman.git
synced 2025-06-24 03:08:13 +08:00
Fix podman build handling of --http-proxy flag
Also fixed a todo for handling of cgroup manager while I was in there. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/containers/buildah/imagebuildah"
|
"github.com/containers/buildah/imagebuildah"
|
||||||
buildahCLI "github.com/containers/buildah/pkg/cli"
|
buildahCLI "github.com/containers/buildah/pkg/cli"
|
||||||
"github.com/containers/buildah/pkg/parse"
|
"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/registry"
|
||||||
"github.com/containers/libpod/cmd/podman/utils"
|
"github.com/containers/libpod/cmd/podman/utils"
|
||||||
"github.com/containers/libpod/pkg/domain/entities"
|
"github.com/containers/libpod/pkg/domain/entities"
|
||||||
@ -396,16 +397,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
runtimeFlags = append(runtimeFlags, "--"+arg)
|
runtimeFlags = append(runtimeFlags, "--"+arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: the code below needs to be enabled (and adjusted) once the
|
containerConfig := registry.PodmanConfig()
|
||||||
// global/root flags are supported.
|
if containerConfig.Engine.CgroupManager == config.SystemdCgroupsManager {
|
||||||
|
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
|
||||||
// conf, err := runtime.GetConfig()
|
}
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// if conf != nil && conf.Engine.CgroupManager == config.SystemdCgroupsManager {
|
|
||||||
// runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
|
|
||||||
// }
|
|
||||||
|
|
||||||
opts := imagebuildah.BuildOptions{
|
opts := imagebuildah.BuildOptions{
|
||||||
AddCapabilities: flags.CapAdd,
|
AddCapabilities: flags.CapAdd,
|
||||||
@ -418,12 +413,13 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
CNIPluginPath: flags.CNIPlugInPath,
|
CNIPluginPath: flags.CNIPlugInPath,
|
||||||
CommonBuildOpts: &buildah.CommonBuildOptions{
|
CommonBuildOpts: &buildah.CommonBuildOptions{
|
||||||
AddHost: flags.AddHost,
|
AddHost: flags.AddHost,
|
||||||
CgroupParent: flags.CgroupParent,
|
|
||||||
CPUPeriod: flags.CPUPeriod,
|
CPUPeriod: flags.CPUPeriod,
|
||||||
CPUQuota: flags.CPUQuota,
|
CPUQuota: flags.CPUQuota,
|
||||||
CPUShares: flags.CPUShares,
|
|
||||||
CPUSetCPUs: flags.CPUSetCPUs,
|
CPUSetCPUs: flags.CPUSetCPUs,
|
||||||
CPUSetMems: flags.CPUSetMems,
|
CPUSetMems: flags.CPUSetMems,
|
||||||
|
CPUShares: flags.CPUShares,
|
||||||
|
CgroupParent: flags.CgroupParent,
|
||||||
|
HTTPProxy: flags.HTTPProxy,
|
||||||
Memory: memoryLimit,
|
Memory: memoryLimit,
|
||||||
MemorySwap: memorySwap,
|
MemorySwap: memorySwap,
|
||||||
ShmSize: flags.ShmSize,
|
ShmSize: flags.ShmSize,
|
||||||
|
@ -195,4 +195,21 @@ var _ = Describe("Podman build", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
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")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user