62
62
)
63
63
64
64
func init () {
65
- slog .Info ("===== Init container =====" )
65
+ slog .Info ("===== Runing 'init' =====" )
66
66
// Set log level based on environment variable
67
67
var logLevel slog.Level
68
68
slogLevel , err := strconv .Atoi (os .Getenv ("LOG_LEVEL" ))
@@ -149,7 +149,7 @@ func init() {
149
149
}
150
150
151
151
func Handle (w http.ResponseWriter , r * http.Request ) {
152
- slog .Info ("===== Starting purge =====" )
152
+ slog .Info ("===== Runing 'Handle' =====" )
153
153
// Get Retention date
154
154
retentionDate := time .Now ().AddDate (0 , 0 , - config .RetentionDays )
155
155
slog .Info (fmt .Sprintf ("Purging images older than: %s" , retentionDate .Format (time .RFC3339 )))
@@ -196,15 +196,15 @@ func Handle(w http.ResponseWriter, r *http.Request) {
196
196
for _ , tag := range tags {
197
197
// Check if tag is older than retention date
198
198
if tag .UpdatedAt .Before (retentionDate ) {
199
- slog .Info (fmt .Sprintf ("Tag %s:%s updated at %s is older than retention date %s" ,
199
+ slog .Debug (fmt .Sprintf ("Tag %s:%s updated at %s is older than retention date %s" ,
200
200
image .Name , tag .Name , tag .UpdatedAt .Format (time .RFC3339 ), retentionDate .Format (time .RFC3339 )))
201
201
202
202
// Check if tag is protected
203
203
if config .PreserveTagPatterns .MatchString (tag .Name ) {
204
- slog .Info (fmt .Sprintf ("Tag %s match protection pattern. Preserving" , tag .Name ))
204
+ slog .Debug (fmt .Sprintf ("Tag %s match protection pattern. Preserving" , tag .Name ))
205
205
preservedTags ++
206
206
} else {
207
- slog .Info (fmt .Sprintf ("Tag %s doesn't match protection pattern." , tag .Name ))
207
+ slog .Debug (fmt .Sprintf ("Tag %s doesn't match protection pattern." , tag .Name ))
208
208
// Delete tag if not dry run
209
209
if err := registryClient .DeleteTag (context .Background (), tag ); err != nil {
210
210
slog .Error (fmt .Sprintf ("Failed to delete tag %s (%s): %v" , tag .Name , tag .ID , err ))
@@ -214,7 +214,7 @@ func Handle(w http.ResponseWriter, r *http.Request) {
214
214
deletedTags ++
215
215
}
216
216
} else {
217
- slog .Info (fmt .Sprintf ("Tag %s updated at %s is newer than retention date %s. Skipping" ,
217
+ slog .Debug (fmt .Sprintf ("Tag %s updated at %s is newer than retention date %s. Skipping" ,
218
218
tag .Name , tag .UpdatedAt .Format (time .RFC3339 ), retentionDate .Format (time .RFC3339 )))
219
219
skippedTags ++
220
220
}
@@ -233,7 +233,7 @@ func Handle(w http.ResponseWriter, r *http.Request) {
233
233
// DeleteTag deletes a tag
234
234
func (r * RegistryClient ) DeleteTag (ctx context.Context , tag * registry.Tag ) error {
235
235
if r .config .DryRun {
236
- slog .Info (fmt .Sprintf ("[DRY RUN] Would delete tag: %s (%s)" , tag .Name , tag .ID ))
236
+ slog .Debug (fmt .Sprintf ("[DRY RUN] Would delete tag: %s (%s)" , tag .Name , tag .ID ))
237
237
return nil
238
238
}
239
239
0 commit comments