Skip to content

Commit f7fb540

Browse files
committed
Additional info and error logs
1 parent fac5b89 commit f7fb540

File tree

1 file changed

+8
-3
lines changed
  • components/image-builder-mk3/pkg/auth

1 file changed

+8
-3
lines changed

components/image-builder-mk3/pkg/auth/auth.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (a *DockerConfigFileAuth) loadFromFile(fn string) (err error) {
7777
_, _ = hash.Write(cntnt)
7878
newHash := fmt.Sprintf("%x", hash.Sum(nil))
7979
if a.hash == newHash {
80+
log.Infof("nothing has changed: %s", fn)
8081
return nil
8182
}
8283

@@ -101,6 +102,7 @@ func (a *DockerConfigFileAuth) loadFromFile(fn string) (err error) {
101102
func (a *DockerConfigFileAuth) Authenticate(ctx context.Context, registry string) (auth *Authentication, err error) {
102103
ac, err := a.C.GetAuthConfig(registry)
103104
if err != nil {
105+
log.WithError(err).WithField("registry", registry).Error("failed DockerConfigFileAuth Authenticate")
104106
return nil, err
105107
}
106108

@@ -122,7 +124,7 @@ func (ca CompositeAuth) Authenticate(ctx context.Context, registry string) (auth
122124
for _, ath := range ca {
123125
res, err := ath.Authenticate(ctx, registry)
124126
if err != nil {
125-
log.WithError(err).Errorf("failed composite authenticate")
127+
log.WithError(err).WithField("registry", registry).Errorf("failed CompositeAuth Authenticate")
126128
return nil, err
127129
}
128130
if !res.Empty() {
@@ -173,7 +175,8 @@ func (ath *ECRAuthenticator) Authenticate(ctx context.Context, registry string)
173175
return nil, err
174176
}
175177
if len(tknout.AuthorizationData) == 0 {
176-
return nil, fmt.Errorf("no ECR authorization data received")
178+
err = fmt.Errorf("no ECR authorization data received")
179+
return nil, err
177180
}
178181

179182
pwd, err := base64.StdEncoding.DecodeString(aws.ToString(tknout.AuthorizationData[0].AuthorizationToken))
@@ -184,6 +187,8 @@ func (ath *ECRAuthenticator) Authenticate(ctx context.Context, registry string)
184187
ath.ecrAuth = string(pwd)
185188
ath.ecrAuthLastRefreshTime = time.Now()
186189
log.Info("refreshed ECR token")
190+
} else {
191+
log.Info("no ECR token refresh necessary")
187192
}
188193

189194
segs := strings.Split(ath.ecrAuth, ":")
@@ -373,7 +378,7 @@ func (a AllowedAuthFor) additionalAuth(domain string) *Authentication {
373378
res.Password = strings.Join(segs[1:], ":")
374379
}
375380
} else {
376-
log.WithError(err).Errorf("failed getting additional auth")
381+
log.Errorf("failed getting additional auth")
377382
}
378383
return res
379384
}

0 commit comments

Comments
 (0)