1
0
mirror of https://github.com/moby/buildkit.git synced 2025-08-01 02:04:26 +03:00

solver: fix reading secrets from any session

The current logic was incorrect in some places so that if first
session randomly chosen by `Any()` returned NotFound then other
sessions were not attempted.

For the main use case of mounting secrets as files the logic
was correct, but it was incorrect for example for the case of
adding secrets as environment variables.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-03-11 15:17:50 -07:00
parent 3da6d960df
commit 91b55e89e5
3 changed files with 11 additions and 11 deletions

View File

@ -256,9 +256,11 @@ func (gs *gitSourceHandler) getAuthToken(ctx context.Context, g session.Group) e
if err != nil {
return err
}
return gs.sm.Any(ctx, g, func(ctx context.Context, _ string, caller session.Caller) error {
err = gs.sm.Any(ctx, g, func(ctx context.Context, _ string, caller session.Caller) error {
var err error
for _, s := range sec {
dt, err := secrets.GetSecret(ctx, caller, s.name)
var dt []byte
dt, err = secrets.GetSecret(ctx, caller, s.name)
if err != nil {
if errors.Is(err, secrets.ErrNotFound) {
continue
@ -271,8 +273,12 @@ func (gs *gitSourceHandler) getAuthToken(ctx context.Context, g session.Group) e
gs.authArgs = []string{"-c", "http." + tokenScope(gs.src.Remote) + ".extraheader=Authorization: " + string(dt)}
break
}
return nil
return err
})
if errors.Is(err, secrets.ErrNotFound) {
err = nil
}
return err
}
func (gs *gitSourceHandler) mountSSHAuthSock(ctx context.Context, sshID string, g session.Group) (string, func() error, error) {