mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit with typed errors support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
33
vendor/github.com/moby/buildkit/session/auth/auth.go
generated
vendored
33
vendor/github.com/moby/buildkit/session/auth/auth.go
generated
vendored
@ -4,24 +4,33 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/moby/buildkit/session"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/moby/buildkit/util/grpcerrors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func CredentialsFunc(ctx context.Context, c session.Caller) func(string) (string, string, error) {
|
||||
return func(host string) (string, string, error) {
|
||||
client := NewAuthClient(c.Conn())
|
||||
func CredentialsFunc(sm *session.Manager, g session.Group) func(string) (session, username, secret string, err error) {
|
||||
return func(host string) (string, string, string, error) {
|
||||
var sessionID, user, secret string
|
||||
err := sm.Any(context.TODO(), g, func(ctx context.Context, id string, c session.Caller) error {
|
||||
client := NewAuthClient(c.Conn())
|
||||
|
||||
resp, err := client.Credentials(ctx, &CredentialsRequest{
|
||||
Host: host,
|
||||
resp, err := client.Credentials(ctx, &CredentialsRequest{
|
||||
Host: host,
|
||||
})
|
||||
if err != nil {
|
||||
if grpcerrors.Code(err) == codes.Unimplemented {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
sessionID = id
|
||||
user = resp.Username
|
||||
secret = resp.Secret
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
if st, ok := status.FromError(errors.Cause(err)); ok && st.Code() == codes.Unimplemented {
|
||||
return "", "", nil
|
||||
}
|
||||
return "", "", errors.WithStack(err)
|
||||
return "", "", "", err
|
||||
}
|
||||
return resp.Username, resp.Secret, nil
|
||||
return sessionID, user, secret, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user