Skip to content

Commit

Permalink
podman build enable --all-platforms and --unsetenv
Browse files Browse the repository at this point in the history
Make sure we add support for allplatforms and unsetenv to both local and
remote podman.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
  • Loading branch information
Luap99 committed Jan 13, 2022
1 parent b240635 commit 8e3747c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/podman/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
opts := buildahDefine.BuildOptions{
AddCapabilities: flags.CapAdd,
AdditionalTags: tags,
AllPlatforms: flags.AllPlatforms,
Annotations: flags.Annotation,
Args: args,
BlobDirectory: flags.BlobCache,
CNIConfigDir: flags.CNIConfigDir,
CNIPluginPath: flags.CNIPlugInPath,
CommonBuildOpts: commonOpts,
Compression: compression,
ConfigureNetwork: networkPolicy,
Expand Down Expand Up @@ -559,6 +558,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
SystemContext: systemContext,
Target: flags.Target,
TransientMounts: flags.Volumes,
UnsetEnvs: flags.UnsetEnvs,
}

if flags.IgnoreFile != "" {
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
AdditionalCapabilities string `schema:"addcaps"`
Annotations string `schema:"annotations"`
AppArmor string `schema:"apparmor"`
AllPlatforms bool `schema:"allplatforms"`
BuildArgs string `schema:"buildargs"`
CacheFrom string `schema:"cachefrom"`
Compression uint64 `schema:"compression"`
Expand Down Expand Up @@ -121,6 +122,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Target string `schema:"target"`
Timestamp int64 `schema:"timestamp"`
Ulimits string `schema:"ulimits"`
UnsetEnvs []string `schema:"unsetenv"`
Secrets string `schema:"secrets"`
}{
Dockerfile: "Dockerfile",
Expand Down Expand Up @@ -495,6 +497,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
AdditionalTags: additionalTags,
Annotations: annotations,
Args: buildArgs,
AllPlatforms: query.AllPlatforms,
CommonBuildOpts: &buildah.CommonBuildOptions{
AddHost: addhosts,
ApparmorProfile: apparmor,
Expand Down Expand Up @@ -548,6 +551,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Squash: query.Squash,
Target: query.Target,
SystemContext: systemContext,
UnsetEnvs: query.UnsetEnvs,
}

for _, platformSpec := range query.Platform {
Expand Down
14 changes: 14 additions & 0 deletions pkg/api/server/register_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,14 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// default: latest
// description: A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default latest value is assumed. You can provide several t parameters.
// - in: query
// name: allplatforms
// type: boolean
// default: false
// description: |
// Instead of building for a set of platforms specified using the platform option, inspect the build's base images,
// and build for all of the platforms that are available. Stages that use *scratch* as a starting point can not be inspected,
// so at least one non-*scratch* stage must be present for detection to work usefully.
// - in: query
// name: extrahosts
// type: string
// default:
Expand Down Expand Up @@ -1570,6 +1578,12 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// description: |
// Inject http proxy environment variables into container
// (As of version 2.0.0)
// - in: query
// name: unsetenv
// description: Unset environment variables from the final image.
// type: array
// items:
// type: string
// produces:
// - application/json
// responses:
Expand Down
10 changes: 10 additions & 0 deletions pkg/bindings/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
}
params.Set("annotations", l)
}

if options.AllPlatforms {
params.Add("allplatforms", "1")
}

params.Add("t", options.Output)
for _, tag := range options.AdditionalTags {
params.Add("t", tag)
Expand Down Expand Up @@ -289,6 +294,11 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
}
params.Set("ulimits", string(ulimitsJSON))
}

for _, uenv := range options.UnsetEnvs {
params.Add("unsetenv", uenv)
}

var (
headers map[string]string
err error
Expand Down

0 comments on commit 8e3747c

Please sign in to comment.