/
progress.go
36 lines (30 loc) · 1.31 KB
/
progress.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors
// Package oci contains functions for interacting with artifacts stored in OCI registries.
package oci
import (
"context"
"fmt"
"github.com/defenseunicorns/zarf/src/pkg/utils/helpers"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// printLayerSkipped prints a debug message when a layer has been successfully skipped.
func (o *OrasRemote) printLayerSkipped(_ context.Context, desc ocispec.Descriptor) error {
return o.printLayer(desc, "skipped")
}
// printLayerCopied prints a debug message when a layer has been successfully copied to/from a registry.
func (o *OrasRemote) printLayerCopied(_ context.Context, desc ocispec.Descriptor) error {
return o.printLayer(desc, "copied")
}
// printLayer prints a debug message when a layer has been successfully published/pulled to/from a registry.
func (o *OrasRemote) printLayer(desc ocispec.Descriptor, suffix string) error {
title := desc.Annotations[ocispec.AnnotationTitle]
var layerInfo string
if title != "" {
layerInfo = fmt.Sprintf("%s %s", desc.Digest.Encoded()[:12], helpers.First30last30(title))
} else {
layerInfo = fmt.Sprintf("%s [%s]", desc.Digest.Encoded()[:12], desc.MediaType)
}
o.log.Debug(fmt.Sprintf("%s (%s)", layerInfo, suffix))
return nil
}