Skip to content

Commit 774d121

Browse files
Address AI feedback
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent 38bb55b commit 774d121

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cla-backend-go/template/repository.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,13 @@ func (r Repository) GetTemplateName(ctx context.Context, templateID string) (str
145145

146146
// For each template...
147147
templateMapMutex.RLock()
148+
defer templateMapMutex.RUnlock()
148149
for _, template := range templateMap {
149150
// If we have a match
150151
if template.ID == templateID {
151-
templateMapMutex.RUnlock()
152152
return template.Name, nil
153153
}
154154
}
155-
templateMapMutex.RUnlock()
156155

157156
log.WithFields(f).Warnf("unable to locate template with ID: %s", templateID)
158157
return "", nil

cla-backend-go/token/token.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ func retrieveToken() error {
112112
tokenMutex.Unlock()
113113

114114
tokenExpiry := time.Now().Add(time.Second * time.Duration(tr.ExpiresIn))
115-
log.WithFields(f).Debugf("retrieved token: %s... expires: %s", token[0:8], tokenExpiry.UTC().String())
115+
tokenMutex.RLock()
116+
tokenForLog := token
117+
tokenMutex.RUnlock()
118+
log.WithFields(f).Debugf("retrieved token: %s... expires: %s", tokenForLog[0:8], tokenExpiry.UTC().String())
116119

117120
return nil
118121
}

0 commit comments

Comments
 (0)