diff --git a/internal/ghpackage/retention.go b/internal/ghpackage/retention.go index a8a6835..3444880 100644 --- a/internal/ghpackage/retention.go +++ b/internal/ghpackage/retention.go @@ -80,6 +80,7 @@ func (a *RetentionManager) findPackages(ctx context.Context, packageName string, switch a.PackageType { case "container": if !a.matchContainer(version) { + a.Logger.V(1).Info("skip package version as version does not match the required match regex", "package", packageName, "version", *version.Name, "id", *version.ID) continue } @@ -93,17 +94,20 @@ func (a *RetentionManager) findPackages(ctx context.Context, packageName string, } default: if !a.VersionMatch.MatchString(*version.Name) { + a.Logger.V(1).Info("skip package version as version does not match the required match regex", "package", packageName, "version", *version.Name, "id", *version.ID) continue } } } if version.UpdatedAt == nil { + a.Logger.V(1).Info("skip package version as no update timestamp exists", "package", packageName, "version", *version.Name, "id", *version.ID) continue } if a.Age != 0 { if version.UpdatedAt.Time.Add(a.Age).After(time.Now()) { + a.Logger.V(1).Info("skip package version as age is too new", "package", packageName, "version", *version.Name, "id", *version.ID, "age", version.UpdatedAt) continue } } diff --git a/main.go b/main.go index cb20433..9d2b85e 100644 --- a/main.go +++ b/main.go @@ -100,18 +100,24 @@ func main() { logger: log, } + containerTransport := &loggingRoundTripper{ + next: http.DefaultTransport, + logger: log, + } + ghClient := github.NewClient(tc) a := ghpackage.RetentionManager{ - PackageType: viper.GetString("package-type"), - Token: token, - DryRun: viper.GetBool("dry-run"), - GithubClient: ghClient, - PackageNames: packages, - Age: viper.GetDuration("age"), - OrganizationName: viper.GetString("org-name"), - VersionMatch: versionMatchRegexp, - Logger: log, + ContainerRegistryTransport: containerTransport, + PackageType: strings.ToLower(viper.GetString("package-type")), + Token: token, + DryRun: viper.GetBool("dry-run"), + GithubClient: ghClient, + PackageNames: packages, + Age: viper.GetDuration("age"), + OrganizationName: strings.ToLower(viper.GetString("org-name")), + VersionMatch: versionMatchRegexp, + Logger: log, } _, err = a.Run(ctx) @@ -126,6 +132,6 @@ type loggingRoundTripper struct { func (p loggingRoundTripper) RoundTrip(req *http.Request) (res *http.Response, e error) { p.logger.V(1).Info("http request sent", "method", req.Method, "uri", req.URL.String()) res, err := p.next.RoundTrip(req) - p.logger.V(1).Info("http response received", "method", req.Method, "uri", req.URL.String(), "status", res.StatusCode) + p.logger.V(1).Info("http response received", "method", req.Method, "uri", req.URL.String(), "status", res.StatusCode, "err", err) return res, err }