summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorAditya R <arajan@redhat.com>2022-05-23 15:47:22 +0530
committerAditya R <arajan@redhat.com>2022-05-26 21:01:18 +0530
commit6124b51993b0a8010b7b276086cf4464e168932a (patch)
tree8f129c7a2b9a6c419f8633ee5d6beb10ea35e02d /cmd
parentb730e7328e9fd1142d84e4a7c4fe213a7aa6d5d9 (diff)
downloadpodman-6124b51993b0a8010b7b276086cf4464e168932a.tar.gz
podman-6124b51993b0a8010b7b276086cf4464e168932a.tar.bz2
podman-6124b51993b0a8010b7b276086cf4464e168932a.zip
build: allow using cache explicitly with --squash-all using --layers
Buildah already supports using `--layers` with `--squash` after https://github.com/containers/buildah/pull/3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: https://github.com/containers/buildah/issues/4011 Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/build.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 36779d6bc..3e7f35e28 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -197,9 +197,8 @@ func buildFlags(cmd *cobra.Command) {
// build executes the build command.
func build(cmd *cobra.Command, args []string) error {
if (cmd.Flags().Changed("squash") && cmd.Flags().Changed("layers")) ||
- (cmd.Flags().Changed("squash-all") && cmd.Flags().Changed("layers")) ||
(cmd.Flags().Changed("squash-all") && cmd.Flags().Changed("squash")) {
- return errors.New("cannot specify --squash, --squash-all and --layers options together")
+ return errors.New("cannot specify --squash with --layers and --squash-all with --squash")
}
if cmd.Flag("output").Changed && registry.IsRemote() {
@@ -418,7 +417,13 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
// Squash-all invoked, squash both new and old layers into one.
if c.Flags().Changed("squash-all") {
flags.Squash = true
- flags.Layers = false
+ if !c.Flags().Changed("layers") {
+ // Buildah supports using layers and --squash together
+ // after https://github.com/containers/buildah/pull/3674
+ // so podman must honor if user wants to still use layers
+ // with --squash-all.
+ flags.Layers = false
+ }
}
var stdin io.Reader