-
Notifications
You must be signed in to change notification settings - Fork 896
Respect compression_format from containers.conf in push, build --cache-to, and commit
#6757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef4b7c1
push: respect compression_format from containers.conf
Honny1 207c045
build: pass compression_format to --cache-to push
Honny1 e6773b3
commit: add --compression-format flag with containers.conf fallback
Honny1 149909e
build: add --compression-format flags for build
Honny1 bf9d66c
docs: document compression flags for commit, push and build
Honny1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import ( | |
| "go.podman.io/buildah/pkg/parse" | ||
| util "go.podman.io/buildah/util" | ||
| "go.podman.io/common/pkg/auth" | ||
| "go.podman.io/common/pkg/config" | ||
| "go.podman.io/image/v5/manifest" | ||
| "go.podman.io/image/v5/pkg/compression" | ||
| "go.podman.io/image/v5/transports" | ||
|
|
@@ -194,14 +195,6 @@ func pushCmd(c *cobra.Command, args []string, iopts pushOptions) error { | |
| return fmt.Errorf("unable to obtain encryption config: %w", err) | ||
| } | ||
|
|
||
| if c.Flag("compression-format").Changed { | ||
| if !c.Flag("force-compression").Changed { | ||
| // If `compression-format` is set and no value for `--force-compression` | ||
| // is selected then defaults to `true`. | ||
| iopts.forceCompressionFormat = true | ||
| } | ||
| } | ||
|
|
||
| options := buildah.PushOptions{ | ||
| Compression: compress, | ||
| ManifestType: manifestType, | ||
|
|
@@ -225,15 +218,33 @@ func pushCmd(c *cobra.Command, args []string, iopts pushOptions) error { | |
| if !iopts.quiet { | ||
| options.ReportWriter = os.Stderr | ||
| } | ||
| defaultContainerConfig, err := config.Default() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get container config: %w", err) | ||
| } | ||
| if iopts.compressionFormat != "" { | ||
| algo, err := compression.AlgorithmByName(iopts.compressionFormat) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| options.CompressionFormat = &algo | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the bit that checks for |
||
| if !c.Flag("force-compression").Changed { | ||
| options.ForceCompressionFormat = true | ||
| } | ||
| } else if defaultContainerConfig.Engine.CompressionFormat != "" && defaultContainerConfig.Engine.CompressionFormat != "gzip" { | ||
| algo, err := compression.AlgorithmByName(defaultContainerConfig.Engine.CompressionFormat) | ||
| if err != nil { | ||
| return fmt.Errorf("parsing compression_format from containers.conf: %w", err) | ||
| } | ||
| options.CompressionFormat = &algo | ||
| if !c.Flag("force-compression").Changed { | ||
| options.ForceCompressionFormat = true | ||
| } | ||
| } | ||
| if c.Flag("compression-level").Changed { | ||
| options.CompressionLevel = &iopts.compressionLevel | ||
| } else { | ||
| options.CompressionLevel = defaultContainerConfig.Engine.CompressionLevel | ||
| } | ||
|
|
||
| ref, digest, err := buildah.Push(getContext(), src, dest, options) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the bit that checks for
c.Flag("compression-format").Changedabove intended to be merged into this block, to parallel the similar logic in the next block?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is much cleaner. I will fix that.