Skip to content

Commit

Permalink
fix: logs about used mirrors
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Jan 20, 2025
1 parent e3a9123 commit 7102e45
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ func Get(ctx context.Context, ref name.Reference, option types.RegistryOptions)
// Other errors
return nil, err
}

if ref.Context().RegistryStr() != r.Context().RegistryStr() {
log.WithPrefix("remote").Info("Mirror was used to get remote image",
log.String("image", ref.String()), log.String("mirror", r.Context().RegistryStr()))
}
return desc, nil
}

// No authentication for mirrors/host succeeded
return nil, errs
}

// tryGet checks all auth options and tries to get Descriptor.
func tryGet(ctx context.Context, tr http.RoundTripper, ref name.Reference, option types.RegistryOptions) (*Descriptor, error) {
var errs error
for _, authOpt := range authOptions(ctx, ref, option) {
Expand Down Expand Up @@ -94,9 +100,6 @@ func tryGet(ctx context.Context, tr http.RoundTripper, ref name.Reference, optio
return nil, err
}
}
if ref.Context().RegistryStr() != ref.Context().RegistryStr() {
log.WithPrefix("remote").Info("Mirror was used to get remote image", log.String("image", ref.String()), log.String("mirror", ref.Context().RegistryStr()))
}
return desc, nil
}
return nil, errs
Expand Down Expand Up @@ -126,6 +129,10 @@ func Image(ctx context.Context, ref name.Reference, option types.RegistryOptions
continue

}
if ref.Context().RegistryStr() != r.Context().RegistryStr() {
log.WithPrefix("remote").Info("Mirror was used to get remote image",
log.String("image", ref.String()), log.String("mirror", r.Context().RegistryStr()))
}
return image, nil
}

Expand All @@ -148,10 +155,6 @@ func tryImage(ctx context.Context, tr http.RoundTripper, ref name.Reference, opt
continue
}

if ref.Context().RegistryStr() != ref.Context().RegistryStr() {
log.WithPrefix("remote").Info("Mirror was used to get remote image",
log.String("image", ref.String()), log.String("mirror", ref.Context().RegistryStr()))
}
return index, nil
}
return nil, errs
Expand Down

0 comments on commit 7102e45

Please sign in to comment.