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

implement digest #518

Merged
merged 1 commit into from
Dec 20, 2021
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
33 changes: 27 additions & 6 deletions engine/virt/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,34 @@ func (v *Virt) ImageBuildCachePrune(ctx context.Context, all bool) (reclaimed ui
}

// ImageLocalDigests shows local images' digests.
func (v *Virt) ImageLocalDigests(ctx context.Context, image string) (digests []string, err error) {
log.Warnf(ctx, "ImageLocalDigests does not implement")
return
// If local image file not exists return error
// If exists return digests
// Same for remote digest
func (v *Virt) ImageLocalDigests(ctx context.Context, image string) ([]string, error) {
// If not exists return error
// If exists return digests
_, imgName, err := splitUserImage(image)
if err != nil {
return nil, err
}

return v.client.DigestImage(ctx, imgName, true)
}

// ImageRemoteDigest shows remote one's digest.
func (v *Virt) ImageRemoteDigest(ctx context.Context, image string) (digest string, err error) {
log.Warnf(ctx, "ImageRemoteDigest does not implement")
return
func (v *Virt) ImageRemoteDigest(ctx context.Context, image string) (string, error) {
_, imgName, err := splitUserImage(image)
if err != nil {
return "", err
}

digests, err := v.client.DigestImage(ctx, imgName, true)
switch {
case err != nil:
return "", err
case len(digests) < 1:
return "", types.ErrNoRemoteDigest
default:
return digests[0], nil
}
}
1 change: 1 addition & 0 deletions types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var (
ErrNoWorkloadIDs = errors.New("No workload ids given")
ErrRunAndWaitCountOneWithStdin = errors.New("Count must be 1 if OpenStdin is true")
ErrUnknownControlType = errors.New("Unknown control type")
ErrNoRemoteDigest = errors.New("got no digest")

ErrNoETCD = errors.New("ETCD must be set")
ErrKeyNotExists = errors.New("Key not exists")
Expand Down