mirror of
https://github.com/containers/podman.git
synced 2025-07-03 17:27:18 +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
|
return err
|
||||||
}
|
}
|
||||||
extractOpt := &types.ExtractOptions{
|
extractOpt := &types.ExtractOptions{
|
||||||
Digest: opts.Digest,
|
FilterBlobOptions: types.FilterBlobOptions{
|
||||||
Title: opts.Title,
|
Digest: opts.Digest,
|
||||||
|
Title: opts.Title,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return artStore.Extract(ctx, name, target, extractOpt)
|
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 {
|
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)
|
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 {
|
if err != nil {
|
||||||
return err
|
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 {
|
if len(options.Digest) > 0 || len(options.Title) > 0 {
|
||||||
digest, err := findDigest(arty, options)
|
digest, err := findDigest(arty, &options.FilterBlobOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -427,7 +427,7 @@ func generateArtifactBlobName(title string, digest digest.Digest) (string, error
|
|||||||
return filename, nil
|
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
|
var digest digest.Digest
|
||||||
for _, l := range arty.Manifest.Layers {
|
for _, l := range arty.Manifest.Layers {
|
||||||
if options.Digest == l.Digest.String() {
|
if options.Digest == l.Digest.String() {
|
||||||
|
@ -12,9 +12,16 @@ type AddOptions struct {
|
|||||||
Append bool `json:",omitempty"`
|
Append bool `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExtractOptions struct {
|
// FilterBlobOptions options used to filter for a single blob in an artifact
|
||||||
// Title annotation value to extract only a single blob matching that name. Optional.
|
type FilterBlobOptions struct {
|
||||||
|
// Title annotation value to extract only a single blob matching that name.
|
||||||
|
// Optional. Conflicts with Digest.
|
||||||
Title string
|
Title string
|
||||||
// Digest of the blob to extract. Optional.
|
// Digest of the blob to extract.
|
||||||
|
// Optional. Conflicts with Title.
|
||||||
Digest string
|
Digest string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExtractOptions struct {
|
||||||
|
FilterBlobOptions
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user