Skip to content

Commit 46cec01

Browse files
authored
feat: add more logging to packager2.Pull (#3557)
Signed-off-by: Kit Patella <[email protected]>
1 parent 0495cef commit 46cec01

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/internal/packager2/pull.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"github.com/zarf-dev/zarf/src/pkg/logger"
1011
"io"
1112
"net/http"
1213
"net/url"
1314
"os"
1415
"path/filepath"
1516
"strings"
17+
"time"
1618

1719
"github.com/defenseunicorns/pkg/helpers/v2"
1820
"github.com/defenseunicorns/pkg/oci"
@@ -31,6 +33,8 @@ import (
3133

3234
// Pull fetches the Zarf package from the given sources.
3335
func Pull(ctx context.Context, src, dir, shasum string, filter filters.ComponentFilterStrategy, publicKeyPath string, skipSignatureValidation bool) error {
36+
l := logger.From(ctx)
37+
start := time.Now()
3438
u, err := url.Parse(src)
3539
if err != nil {
3640
return err
@@ -52,11 +56,13 @@ func Pull(ctx context.Context, src, dir, shasum string, filter filters.Component
5256
isPartial := false
5357
switch u.Scheme {
5458
case "oci":
59+
l.Info("starting pull from oci source", "src", src, "digest", shasum)
5560
isPartial, tmpPath, err = pullOCI(ctx, src, tmpDir, shasum, filter)
5661
if err != nil {
5762
return err
5863
}
5964
case "http", "https":
65+
l.Info("starting pull from http(s) source", "src", src, "digest", shasum)
6066
tmpPath, err = pullHTTP(ctx, src, tmpDir, shasum)
6167
if err != nil {
6268
return err
@@ -99,6 +105,8 @@ func Pull(ctx context.Context, src, dir, shasum string, filter filters.Component
99105
if err != nil {
100106
return err
101107
}
108+
109+
l.Debug("done packager2.Pull", "src", src, "dir", dir, "duration", time.Since(start))
102110
return nil
103111
}
104112

@@ -112,13 +120,14 @@ func pullOCI(ctx context.Context, src, tarDir, shasum string, filter filters.Com
112120
src = fmt.Sprintf("%s@sha256:%s", src, shasum)
113121
}
114122
arch := config.GetArch()
115-
remote, err := zoci.NewRemote(ctx, src, oci.PlatformForArch(arch))
123+
platform := oci.PlatformForArch(arch)
124+
remote, err := zoci.NewRemote(ctx, src, platform)
116125
if err != nil {
117126
return false, "", err
118127
}
119128
desc, err := remote.ResolveRoot(ctx)
120129
if err != nil {
121-
return false, "", fmt.Errorf("could not fetch images index: %w", err)
130+
return false, "", fmt.Errorf("could not find package %s with architecture %s: %w", src, platform.Architecture, err)
122131
}
123132
layersToPull := []ocispec.Descriptor{}
124133
isPartial := false

0 commit comments

Comments
 (0)