Skip to content

Commit

Permalink
change init logs and pull logs
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
  • Loading branch information
AustinAbro321 committed Nov 4, 2024
1 parent 2260b94 commit 2088d4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cmd/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func findInitPackage(ctx context.Context, initPackageName string) (string, error
func downloadInitPackage(ctx context.Context, cacheDirectory string) (string, error) {
l := logger.From(ctx)
url := zoci.GetInitPackageURL(config.CLIVersion)
message.Infof("init package was not found locally. Pulling package %s", url)
l.Info("init package was not found locally. Pulling package", "url", url)
message.Infof("init package was not found locally. Downloading to cache %s", cacheDirectory)
l.Info("init package was not found locally. Downloading to cache", "cache", cacheDirectory)
remote, err := zoci.NewRemote(ctx, url, oci.PlatformForArch(config.GetArch()))
if err != nil {
return "", err
Expand Down
6 changes: 4 additions & 2 deletions src/pkg/zoci/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ var (
// - zarf.yaml.sig
func (r *Remote) PullPackage(ctx context.Context, destinationDir string, concurrency int, layersToPull ...ocispec.Descriptor) (_ []ocispec.Descriptor, err error) {
isPartialPull := len(layersToPull) > 0
r.Log().Debug(fmt.Sprintf("Pulling %s", r.Repo().Reference))

manifest, err := r.FetchRoot(ctx)
if err != nil {
Expand All @@ -52,11 +51,14 @@ func (r *Remote) PullPackage(ctx context.Context, destinationDir string, concurr
}
layersToPull = append(layersToPull, manifest.Config)

layerSize := oci.SumDescsSize(layersToPull)
// TODO (@austinabro321) change this and other r.Log() calls to the proper slog format
r.Log().Info(fmt.Sprintf("Pulling %s, size: %s", r.Repo().Reference, utils.ByteFormat(float64(layerSize), 2)))

// Create a thread to update a progress bar as we save the package to disk
doneSaving := make(chan error)
successText := fmt.Sprintf("Pulling %q", helpers.OCIURLPrefix+r.Repo().Reference.String())

layerSize := oci.SumDescsSize(layersToPull)
go utils.RenderProgressBarForLocalDirWrite(destinationDir, layerSize, doneSaving, "Pulling", successText)

dst, err := file.New(destinationDir)
Expand Down

0 comments on commit 2088d4e

Please sign in to comment.