Skip to content

Commit bb2780f

Browse files
committed
feat: add authentication details to image syncing logs
1 parent bc02802 commit bb2780f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/sync/images.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func SyncImage(ctx context.Context, image *structs.Image) error {
8787
Strs("targets", image.Targets).
8888
Msg("Syncing image")
8989

90-
pullAuth, _ := getAuth(image.GetSourceRegistry(), image.GetSourceRepository())
90+
pullAuth, pullAuthName := getAuth(image.GetSourceRegistry(), image.GetSourceRepository())
9191

9292
puller, err := remote.NewPuller(pullAuth)
9393
if err != nil {
@@ -107,6 +107,7 @@ func SyncImage(ctx context.Context, image *structs.Image) error {
107107
// Get all tags from source
108108
log.Info().
109109
Str("image", image.Source).
110+
Str("auth", pullAuthName).
110111
Msg("Fetching tags")
111112

112113
var srcTags []string
@@ -122,24 +123,26 @@ func SyncImage(ctx context.Context, image *structs.Image) error {
122123

123124
log.Info().
124125
Str("image", image.Source).
126+
Str("auth", pullAuthName).
125127
Int("tags", len(srcTags)).
126128
Msg("Found tags")
127129

128130
// Get all tags from targets
129131
var dstTags []string
130132

131133
for _, dst := range image.Targets {
132-
log.Info().
133-
Str("image", image.Source).
134-
Str("target", dst).
135-
Msg("Fetching destination tags")
136-
137134
dstRepo, err := name.NewRepository(dst)
138135
if err != nil {
139136
return err
140137
}
141138

142-
pushAuth, _ := getAuth(image.GetRegistry(dst), image.GetRepository(dst))
139+
pushAuth, pushAuthName := getAuth(image.GetRegistry(dst), image.GetRepository(dst))
140+
141+
log.Info().
142+
Str("image", image.Source).
143+
Str("target", dst).
144+
Str("auth", pushAuthName).
145+
Msg("Fetching destination tags")
143146

144147
dstPuller, err := remote.NewPuller(pushAuth)
145148
if err != nil {
@@ -166,6 +169,7 @@ func SyncImage(ctx context.Context, image *structs.Image) error {
166169
Str("image", image.Source).
167170
Str("target", dst).
168171
Int("tags", len(dstTags)).
172+
Str("auth", pushAuthName).
169173
Msg("Found destination tags")
170174
}
171175

0 commit comments

Comments
 (0)