Skip to content
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
4 changes: 2 additions & 2 deletions internal/mirror/cmd/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func pull(cmd *cobra.Command, _ []string) error {
puller.logger.WarnLn("Operation cancelled by user")
return nil
}
return ErrPullFailed
return fmt.Errorf("pull failed: %w", err)
}

return nil
Expand Down Expand Up @@ -307,7 +307,7 @@ func (p *Puller) Execute(ctx context.Context) error {
p.logger.WarnLn("Operation cancelled by user")
return nil
}
return err
return fmt.Errorf("pull from registry: %w", err)
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions internal/mirror/cmd/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func pushStaticPackages(pushParams *params.PushParams, logger params.Logger, cli
logger.InfoLn(pkgName, "package is not present, skipping")
continue
case err != nil:
return err
return fmt.Errorf("open package %q: %w", pkgName, err)
}

switch pkgName {
Expand Down Expand Up @@ -236,7 +236,7 @@ func validateRegistryAccess(ctx context.Context, pushParams *params.PushParams)
accessValidator := validation.NewRemoteRegistryAccessValidator()
err := accessValidator.ValidateWriteAccessForRepo(ctx, path.Join(pushParams.RegistryHost, pushParams.RegistryPath), opts...)
if err != nil {
return err
return fmt.Errorf("validate write access to registry %s: %w", path.Join(pushParams.RegistryHost, pushParams.RegistryPath), err)
}

return nil
Expand Down Expand Up @@ -359,7 +359,7 @@ func (p *Pusher) executeNewPush() error {
p.logger.WarnLn("Operation cancelled by user")
return nil
}
return err
return fmt.Errorf("push to registry: %w", err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/mirror/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (svc *Service) validateModulesAccess(ctx context.Context) error {
}

if err != nil {
return fmt.Errorf("failed to check modules lists: %w", err)
return fmt.Errorf("failed to list modules from registry: %w", err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/mirror/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (svc *Service) validatePlatformAccess(ctx context.Context) error {
if internal.ChannelIsValid(targetTag) {
err := svc.deckhouseService.ReleaseChannels().CheckImageExists(ctx, targetTag)
if err != nil {
return fmt.Errorf("failed to check release exists: %w", err)
return fmt.Errorf("failed to check release channel %q exists in registry: %w", targetTag, err)
}

return nil
Expand All @@ -168,7 +168,7 @@ func (svc *Service) validatePlatformAccess(ctx context.Context) error {
// For specific tags, check if the tag exists
err := svc.deckhouseService.CheckImageExists(ctx, targetTag)
if err != nil {
return fmt.Errorf("failed to check tag exists: %w", err)
return fmt.Errorf("failed to check Deckhouse tag %q exists in registry: %w", targetTag, err)
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions internal/mirror/puller/puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (ps *PullerService) PullImages(ctx context.Context, config PullConfig) erro
continue
}

return fmt.Errorf("get digest: %w", err)
return fmt.Errorf("get digest for image %s: %w", tag, err)
}

config.ImageSet[image] = NewImageMeta(tag, image, digest)
Expand Down Expand Up @@ -135,7 +135,7 @@ func (ps *PullerService) PullImageSet(
if err != nil {
logger.Debugf("failed to pull image %s: %v", imageMeta.TagReference, err)

return fmt.Errorf("pull image metadata: %w", err)
return fmt.Errorf("pull image %s (digest %s): %w", imageMeta.TagReference, imageMeta.Digest.String(), err)
}

img.SetMetadata(&image.ImageMeta{
Expand All @@ -148,7 +148,7 @@ func (ps *PullerService) PullImageSet(
if err != nil {
logger.Debugf("failed to add image %s: %v", imageMeta.ImageTag, err)

return fmt.Errorf("add image to layout: %w", err)
return fmt.Errorf("add image %s to layout: %w", imageMeta.ImageTag, err)
}

return nil
Expand Down
14 changes: 7 additions & 7 deletions internal/mirror/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (svc *PushService) unpackAllPackages(ctx context.Context, dirPath string) e

packages := svc.findPackages(entries)
if len(packages) == 0 {
return fmt.Errorf("no packages found in bundle directory")
return fmt.Errorf("no packages found in bundle directory %q", svc.options.BundleDir)
}

svc.userLogger.Infof("Found %d packages to unpack", len(packages))
Expand Down Expand Up @@ -227,7 +227,7 @@ func (svc *PushService) openPackage(pkgName string) (io.ReadCloser, error) {
}

if !os.IsNotExist(err) {
return nil, fmt.Errorf("open %s: %w", tarPath, err)
return nil, fmt.Errorf("open tar package %q: %w", tarPath, err)
}

// Try chunked format
Expand All @@ -239,7 +239,7 @@ func (svc *PushService) openPackage(pkgName string) (io.ReadCloser, error) {
func (svc *PushService) pushAllLayouts(ctx context.Context, rootDir string) error {
layouts, err := svc.findLayouts(rootDir)
if err != nil {
return fmt.Errorf("scan layouts: %w", err)
return fmt.Errorf("scan layouts in %q: %w", rootDir, err)
}

if len(layouts) == 0 {
Expand Down Expand Up @@ -317,7 +317,7 @@ func (svc *PushService) pushSingleLayout(ctx context.Context, rootDir, layoutDir
svc.userLogger.Infof("Pushing %s", targetClient.GetRegistry())

if err := svc.pusher.PushLayout(ctx, layout.Path(layoutDir), targetClient); err != nil {
return fmt.Errorf("push layout %q: %w", relPath, err)
return fmt.Errorf("push layout %q to registry %s: %w", relPath, targetClient.GetRegistry(), err)
}

return nil
Expand Down Expand Up @@ -352,7 +352,7 @@ func (svc *PushService) createModulesIndex(ctx context.Context, rootDir string)
svc.userLogger.InfoLn("No modules directory found, skipping modules index")
return nil
}
return fmt.Errorf("read modules directory: %w", err)
return fmt.Errorf("read modules directory %q: %w", modulesDir, err)
}

// Find all module directories
Expand Down Expand Up @@ -385,12 +385,12 @@ func (svc *PushService) createModulesIndex(ctx context.Context, rootDir string)
// Create minimal random image (32 bytes, 1 layer)
img, err := random.Image(32, 1)
if err != nil {
return fmt.Errorf("create random image for module %s: %w", moduleName, err)
return fmt.Errorf("create random image for module discovery tag %s: %w", moduleName, err)
}

// Push with module name as tag
if err := modulesClient.PushImage(ctx, moduleName, img); err != nil {
return fmt.Errorf("push module index tag %s: %w", moduleName, err)
return fmt.Errorf("push module index tag %s to registry %s: %w", moduleName, modulesClient.GetRegistry(), err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/mirror/pusher/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *Service) PushLayout(ctx context.Context, layoutPath layout.Path, client

img, err := index.Image(manifest.Digest)
if err != nil {
return fmt.Errorf("read image %s: %w", tag, err)
return fmt.Errorf("read image %s from layout %s: %w", tag, layoutPath, err)
}

imageReferenceString := fmt.Sprintf("%s:%s", client.GetRegistry(), tag)
Expand Down
2 changes: 1 addition & 1 deletion internal/mirror/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (svc *Service) validateSecurityAccess(ctx context.Context) error {
}

if err != nil {
return fmt.Errorf("failed to check tag exists: %w", err)
return fmt.Errorf("failed to check security database tag %q in registry: %w", "2", err)
}

return nil
Expand Down