From 495884b3195de482dc610a2a002db7e053188a32 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 17 Dec 2021 14:46:15 +0100 Subject: use libnetwork from c/common The libpod/network packages were moved to c/common so that buildah can use it as well. To prevent duplication use it in podman as well and remove it from here. Signed-off-by: Paul Holzinger --- cmd/podman/common/completion.go | 2 +- cmd/podman/common/create_opts.go | 2 +- cmd/podman/common/netflags.go | 2 +- cmd/podman/containers/ps.go | 2 +- cmd/podman/networks/connect.go | 2 +- cmd/podman/networks/create.go | 4 ++-- cmd/podman/networks/list.go | 2 +- cmd/rootlessport/main.go | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go index f1dea4113..2bd67bf4f 100644 --- a/cmd/podman/common/completion.go +++ b/cmd/podman/common/completion.go @@ -7,11 +7,11 @@ import ( "reflect" "strings" + "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/config" "github.com/containers/image/v5/pkg/sysregistriesv2" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/rootless" systemdDefine "github.com/containers/podman/v3/pkg/systemd/define" diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 297188a45..b4641ea96 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -8,11 +8,11 @@ import ( "strconv" "strings" + "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/cgroups" "github.com/containers/common/pkg/config" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/api/handlers" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/rootless" diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go index 425d85c9d..39b699812 100644 --- a/cmd/podman/common/netflags.go +++ b/cmd/podman/common/netflags.go @@ -3,10 +3,10 @@ package common import ( "net" + "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/completion" "github.com/containers/podman/v3/cmd/podman/parse" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgenutil" diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index cebe61b5a..c8a03ab4f 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -7,13 +7,13 @@ import ( "time" tm "github.com/buger/goterm" + "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/report" "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/utils" "github.com/containers/podman/v3/cmd/podman/validate" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/docker/go-units" "github.com/pkg/errors" diff --git a/cmd/podman/networks/connect.go b/cmd/podman/networks/connect.go index b0ffbfe6d..b0eece06c 100644 --- a/cmd/podman/networks/connect.go +++ b/cmd/podman/networks/connect.go @@ -3,10 +3,10 @@ package network import ( "net" + "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/completion" "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/spf13/cobra" ) diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go index 21d720f55..ad1f9cbd0 100644 --- a/cmd/podman/networks/create.go +++ b/cmd/podman/networks/create.go @@ -4,12 +4,12 @@ import ( "fmt" "net" + "github.com/containers/common/libnetwork/types" + "github.com/containers/common/libnetwork/util" "github.com/containers/common/pkg/completion" "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/parse" "github.com/containers/podman/v3/cmd/podman/registry" - "github.com/containers/podman/v3/libpod/network/types" - "github.com/containers/podman/v3/libpod/network/util" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/pkg/errors" "github.com/sirupsen/logrus" diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go index 7ce566225..b84c9f5d3 100644 --- a/cmd/podman/networks/list.go +++ b/cmd/podman/networks/list.go @@ -6,12 +6,12 @@ import ( "sort" "strings" + "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/report" "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/validate" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/pkg/errors" "github.com/spf13/cobra" diff --git a/cmd/rootlessport/main.go b/cmd/rootlessport/main.go index e691ce2fc..8ac4fe1be 100644 --- a/cmd/rootlessport/main.go +++ b/cmd/rootlessport/main.go @@ -13,7 +13,7 @@ import ( "strings" "github.com/containernetworking/plugins/pkg/ns" - "github.com/containers/podman/v3/libpod/network/types" + "github.com/containers/common/libnetwork/types" "github.com/containers/podman/v3/pkg/rootlessport" "github.com/pkg/errors" rkport "github.com/rootless-containers/rootlesskit/pkg/port" -- cgit v1.2.3-54-g00ecf From 92e7875210d3f6a52b3ef43e8a249022aba5a07c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 13 Jan 2022 14:28:53 +0100 Subject: podman build enable --all-platforms and --unsetenv Make sure we add support for allplatforms and unsetenv to both local and remote podman. Signed-off-by: Paul Holzinger --- cmd/podman/images/build.go | 4 ++-- pkg/api/handlers/compat/images_build.go | 4 ++++ pkg/api/server/register_images.go | 14 ++++++++++++++ pkg/bindings/images/build.go | 10 ++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 751db099f..606c18aae 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -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, @@ -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 != "" { diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 1a5665152..6d4fe5513 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -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"` @@ -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", @@ -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, @@ -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 { diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index bf8eeef40..d9cda8579 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -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: @@ -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: diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 7bca43132..6b5159f52 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -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) @@ -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 -- cgit v1.2.3-54-g00ecf