Skip to content
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

podman-save: Add signature-policy flag #15870

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/podman/images/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func saveFlags(cmd *cobra.Command) {

flags.BoolVarP(&saveOpts.Quiet, "quiet", "q", false, "Suppress the output")
flags.BoolVarP(&saveOpts.MultiImageArchive, "multi-image-archive", "m", containerConfig.Engine.MultiImageArchive, "Interpret additional arguments as images not tags and create a multi-image-archive (only for docker-archive)")

if !registry.IsRemote() {
flags.StringVar(&saveOpts.SignaturePolicy, "signature-policy", "", "Path to a signature-policy file")
_ = flags.MarkHidden("signature-policy")
}
}

func save(cmd *cobra.Command, args []string) (finalErr error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/domain/entities/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ type ImageSaveOptions struct {
// Output - write image to the specified path.
Output string
// Quiet - suppress output when copying images
Quiet bool
Quiet bool
SignaturePolicy string
}

// ImageScpOptions provide options for securely copying images to and from a remote host
Expand Down
1 change: 1 addition & 0 deletions pkg/domain/infra/abi/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string,
saveOptions := &libimage.SaveOptions{}
saveOptions.DirForceCompress = options.Compress
saveOptions.OciAcceptUncompressedLayers = options.OciAcceptUncompressedLayers
saveOptions.SignaturePolicyPath = options.SignaturePolicy

// Force signature removal to preserve backwards compat.
// See https://github.com/containers/podman/pull/11669#issuecomment-925250264
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ var _ = Describe("Podman save", func() {
Expect(save).Should(Exit(0))
})

It("podman save signature-policy flag", func() {
SkipIfRemote("--signature-policy N/A for remote")
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")

save := podmanTest.Podman([]string{"save", "--signature-policy", "/etc/containers/policy.json", "-o", outfile, ALPINE})
save.WaitWithDefaultTimeout()
Expect(save).Should(Exit(0))
})

It("podman save oci flag", func() {
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")

Expand Down