mirror of
https://github.com/containers/podman.git
synced 2025-07-04 09:58:58 +08:00
libartifact: create FilterBlobOptions
The main point of this is so that I can share the same lookup logic between Extract() and then the new blob path API I add next. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -215,8 +215,10 @@ func (ir *ImageEngine) ArtifactExtract(ctx context.Context, name string, target
|
||||
return err
|
||||
}
|
||||
extractOpt := &types.ExtractOptions{
|
||||
FilterBlobOptions: types.FilterBlobOptions{
|
||||
Digest: opts.Digest,
|
||||
Title: opts.Title,
|
||||
},
|
||||
}
|
||||
|
||||
return artStore.Extract(ctx, name, target, extractOpt)
|
||||
|
@ -364,7 +364,7 @@ func (as ArtifactStore) Extract(ctx context.Context, nameOrDigest string, target
|
||||
if len(options.Digest) == 0 && len(options.Title) == 0 {
|
||||
return fmt.Errorf("the artifact consists of several blobs and the target %q is not a directory and neither digest or title was specified to only copy a single blob", target)
|
||||
}
|
||||
digest, err = findDigest(arty, options)
|
||||
digest, err = findDigest(arty, &options.FilterBlobOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -376,7 +376,7 @@ func (as ArtifactStore) Extract(ctx context.Context, nameOrDigest string, target
|
||||
}
|
||||
|
||||
if len(options.Digest) > 0 || len(options.Title) > 0 {
|
||||
digest, err := findDigest(arty, options)
|
||||
digest, err := findDigest(arty, &options.FilterBlobOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -427,7 +427,7 @@ func generateArtifactBlobName(title string, digest digest.Digest) (string, error
|
||||
return filename, nil
|
||||
}
|
||||
|
||||
func findDigest(arty *libartifact.Artifact, options *libartTypes.ExtractOptions) (digest.Digest, error) {
|
||||
func findDigest(arty *libartifact.Artifact, options *libartTypes.FilterBlobOptions) (digest.Digest, error) {
|
||||
var digest digest.Digest
|
||||
for _, l := range arty.Manifest.Layers {
|
||||
if options.Digest == l.Digest.String() {
|
||||
|
@ -12,9 +12,16 @@ type AddOptions struct {
|
||||
Append bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
type ExtractOptions struct {
|
||||
// Title annotation value to extract only a single blob matching that name. Optional.
|
||||
// FilterBlobOptions options used to filter for a single blob in an artifact
|
||||
type FilterBlobOptions struct {
|
||||
// Title annotation value to extract only a single blob matching that name.
|
||||
// Optional. Conflicts with Digest.
|
||||
Title string
|
||||
// Digest of the blob to extract. Optional.
|
||||
// Digest of the blob to extract.
|
||||
// Optional. Conflicts with Title.
|
||||
Digest string
|
||||
}
|
||||
|
||||
type ExtractOptions struct {
|
||||
FilterBlobOptions
|
||||
}
|
||||
|
Reference in New Issue
Block a user