From 4a9dba64725d6c8df612561139cc096569031f17 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Wed, 30 Aug 2023 14:08:23 +0530 Subject: [PATCH] manifest: addCompression use default from containers.conf Replaces: https://github.com/containers/buildah/pull/5014 Signed-off-by: Aditya R Signed-off-by: Daniel J Walsh --- cmd/buildah/from.go | 6 ----- cmd/buildah/main.go | 11 +++++----- cmd/buildah/manifest.go | 2 +- internal/mkcw/embed/entrypoint_amd64.gz | Bin 405 -> 393 bytes tests/bud.bats | 28 +++++++++++++++++++++++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/cmd/buildah/from.go b/cmd/buildah/from.go index 3ee6f8adcc7..135f764dd2f 100644 --- a/cmd/buildah/from.go +++ b/cmd/buildah/from.go @@ -13,7 +13,6 @@ import ( "github.com/containers/buildah/pkg/cli" "github.com/containers/buildah/pkg/parse" "github.com/containers/common/pkg/auth" - "github.com/containers/common/pkg/config" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -188,11 +187,6 @@ func onBuild(builder *buildah.Builder, quiet bool) error { } func fromCmd(c *cobra.Command, args []string, iopts fromReply) error { - defaultContainerConfig, err := config.Default() - if err != nil { - return fmt.Errorf("failed to get container config: %w", err) - } - if len(args) == 0 { return errors.New("an image name (or \"scratch\") must be specified") } diff --git a/cmd/buildah/main.go b/cmd/buildah/main.go index 2e4fa0c06c5..2f602c81643 100644 --- a/cmd/buildah/main.go +++ b/cmd/buildah/main.go @@ -59,8 +59,9 @@ var rootCmd = &cobra.Command{ } var ( - globalFlagResults globalFlags - exitCode int + globalFlagResults globalFlags + exitCode int + defaultContainerConfig *config.Config ) func init() { @@ -79,12 +80,12 @@ func init() { defaultStoreDriverOptions = optionSlice } - containerConfig, err := config.Default() + defaultContainerConfig, err = config.Default() if err != nil { logrus.Errorf(err.Error()) os.Exit(1) } - containerConfig.CheckCgroupsAndAdjustConfig() + defaultContainerConfig.CheckCgroupsAndAdjustConfig() cobra.OnInitialize(initConfig) // Disable the implicit `completion` command in cobra. @@ -98,7 +99,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&globalFlagResults.UserShortNameAliasConfPath, "short-name-alias-conf", "", "path to short name alias cache file (not usually used)") rootCmd.PersistentFlags().StringVar(&globalFlagResults.Root, "root", storageOptions.GraphRoot, "storage root dir") rootCmd.PersistentFlags().StringVar(&globalFlagResults.RunRoot, "runroot", storageOptions.RunRoot, "storage state dir") - rootCmd.PersistentFlags().StringVar(&globalFlagResults.CgroupManager, "cgroup-manager", containerConfig.Engine.CgroupManager, "cgroup manager") + rootCmd.PersistentFlags().StringVar(&globalFlagResults.CgroupManager, "cgroup-manager", defaultContainerConfig.Engine.CgroupManager, "cgroup manager") rootCmd.PersistentFlags().StringVar(&globalFlagResults.StorageDriver, "storage-driver", storageOptions.GraphDriverName, "storage-driver") rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.StorageOpts, "storage-opt", defaultStoreDriverOptions, "storage driver option") rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.UserNSUID, "userns-uid-map", []string{}, "default `ctrID:hostID:length` UID mapping to use") diff --git a/cmd/buildah/manifest.go b/cmd/buildah/manifest.go index 9568d4bc8a3..b417493b9e8 100644 --- a/cmd/buildah/manifest.go +++ b/cmd/buildah/manifest.go @@ -231,7 +231,7 @@ func init() { flags.StringVar(&manifestPushOpts.compressionFormat, "compression-format", "", "compression format to use") flags.IntVar(&manifestPushOpts.compressionLevel, "compression-level", 0, "compression level to use") flags.StringVarP(&manifestPushOpts.format, "format", "f", "", "manifest type (oci or v2s2) to attempt to use when pushing the manifest list (default is manifest type of source)") - flags.StringSliceVar(&manifestPushOpts.addCompression, "add-compression", nil, "add instances with selected compression while pushing") + flags.StringArrayVar(&manifestPushOpts.addCompression, "add-compression", defaultContainerConfig.Engine.AddCompression.Get(), "add instances with selected compression while pushing") flags.BoolVarP(&manifestPushOpts.removeSignatures, "remove-signatures", "", false, "don't copy signatures when pushing images") flags.StringVar(&manifestPushOpts.signBy, "sign-by", "", "sign the image using a GPG key with the specified `FINGERPRINT`") flags.StringVar(&manifestPushOpts.signaturePolicy, "signature-policy", "", "`pathname` of signature policy file (not usually used)") diff --git a/internal/mkcw/embed/entrypoint_amd64.gz b/internal/mkcw/embed/entrypoint_amd64.gz index 980a5a65806dc6281745ffb689858c4e8dbc88c4..947bed9b688479e757c0a11db7076b8774310d7e 100755 GIT binary patch literal 393 zcmV;40e1c$iwFP!000021MQm6O2a@9#wRtcMGy7~WDg!?DV{utsy0(vY3IijB?bf^-&ndNGr}esWJU1T_G&Ho~uvO>VV`b;D z@`8pAZMxIG)th$}{ig0(*Y#j?+&1`jX~o`LT;1vQdTZaV+q|EqM-T)-5ClOG1VNBZ z80F=c`6$mjrMwj%(xd$KQoFsbzI$TsdZowxLJ$N&5ClOG1VNDh$n8XAL_D&X6MYf! zOvDL~h>~Q?NxDb~%LpU)GIx@F<&7V<^7}2n52lA+_2{er4~)=O ne!Jg(U}HxvQ2mEsB>bknu3KNME41~8KaBqYCdfACxFG-lYni%Z literal 405 zcmV;G0c!pqiwFp%I$vb~17&V>a(QrXX>N1??V7(%!!QuWFQF|J4D<<*2S#KeCI*DE z0F{W45byvlF=^CdSBWdi#4GfXDhBc-ya$f|gf<{im4W4clJn)e+{KQ!==^#fUxYyb zo)FH!xL#y@wEpZ!J>-!?F$y $contextdir/Dockerfile1 << _EOF FROM alpine +_EOF + + cat > $contextdir/containers.conf << _EOF +[engine] +add_compression = ["zstd"] _EOF start_registry @@ -28,7 +54,7 @@ _EOF run_buildah manifest add foo image1 run_buildah manifest add foo image2 - run_buildah manifest push $WITH_POLICY_JSON --authfile ${TEST_SCRATCH_DIR}/test.auth --all --add-compression zstd --tls-verify=false foo docker://localhost:${REGISTRY_PORT}/list + CONTAINERS_CONF=$contextdir/containers.conf run_buildah manifest push $WITH_POLICY_JSON --authfile ${TEST_SCRATCH_DIR}/test.auth --all --tls-verify=false foo docker://localhost:${REGISTRY_PORT}/list run_buildah manifest inspect --authfile ${TEST_SCRATCH_DIR}/test.auth --tls-verify=false localhost:${REGISTRY_PORT}/list list="$output"