Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion internal/job/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,19 @@ func (e *Executor) fetchAndSetSecrets(ctx context.Context) error {
Token: e.shell.Env.GetString("BUILDKITE_AGENT_ACCESS_TOKEN", ""),
})

// Fetch all secrets
// Fetch all secrets. We pass secretLogger (a buffer) here because
// FetchSecrets takes a logger.Logger, but retry warnings within it need
// to reach the user. We flush those from the buffer afterwards.
Comment on lines +918 to +920
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire comment read a bit logically odd and misplaced 😅

We pass secretLogger (a buffer) here because FetchSecrets takes a logger.Logger, but retry warnings...

And i think this comment should just be added around the flushing code rather than here.

fetchedSecrets, errs := secrets.FetchSecrets(ctx, secretLogger, apiClient, e.JobID, keys, 10)

// Surface any retry warnings that were buffered during fetching.
// The buffer logger prefixes warn messages with "[warn] ".
for _, msg := range secretLogger.Messages {
if after, ok := strings.CutPrefix(msg, "[warn] "); ok {
e.shell.Warningf("%s", after)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this partially defeating the purpose of using Buffer logger? We haven't mutate redactor at this point, so we are running the risk of exposing secrets to log here.


if len(errs) > 0 {
var errorMsg strings.Builder
for _, err := range errs {
Expand Down