Fix login miss behavior and update op
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
58a67cf86b
commit
2f710b0ce4
@ -2,7 +2,6 @@ package solver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@ -41,9 +40,9 @@ func (a *RegistryAuthProvider) Register(server *grpc.Server) {
|
||||
}
|
||||
|
||||
func (a *RegistryAuthProvider) Credentials(ctx context.Context, req *bkauth.CredentialsRequest) (*bkauth.CredentialsResponse, error) {
|
||||
reqURL, err := parseAuthHost(req.Host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
host := req.Host
|
||||
if host == "registry-1.docker.io" {
|
||||
host = "docker.io"
|
||||
}
|
||||
|
||||
a.m.RLock()
|
||||
@ -55,7 +54,7 @@ func (a *RegistryAuthProvider) Credentials(ctx context.Context, req *bkauth.Cred
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if u.Host == reqURL.Host {
|
||||
if u == host {
|
||||
return auth, nil
|
||||
}
|
||||
}
|
||||
@ -63,23 +62,16 @@ func (a *RegistryAuthProvider) Credentials(ctx context.Context, req *bkauth.Cred
|
||||
return &bkauth.CredentialsResponse{}, nil
|
||||
}
|
||||
|
||||
func parseAuthHost(host string) (*url.URL, error) {
|
||||
func parseAuthHost(host string) (string, error) {
|
||||
host = strings.TrimPrefix(host, "http://")
|
||||
host = strings.TrimPrefix(host, "https://")
|
||||
|
||||
// Retrieve only the registry
|
||||
host = strings.SplitN(host, "/", 2)[0]
|
||||
|
||||
ref, err := reference.ParseNormalizedNamed(host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
host = ref.String()
|
||||
|
||||
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
|
||||
host = "https://" + host
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return url.Parse(host)
|
||||
return reference.Domain(ref), nil
|
||||
}
|
||||
|
||||
func (a *RegistryAuthProvider) FetchToken(ctx context.Context, req *bkauth.FetchTokenRequest) (rr *bkauth.FetchTokenResponse, err error) {
|
||||
|
@ -59,7 +59,7 @@ package op
|
||||
|
||||
#DockerLogin: {
|
||||
do: "docker-login"
|
||||
target: string | *"https://index.docker.io/v1/"
|
||||
target: string
|
||||
username: string
|
||||
// FIXME: should be a #Secret (circular import)
|
||||
secret: string | bytes
|
||||
|
@ -21,6 +21,7 @@ TestPushContainer: {
|
||||
ref: "daggerio/ci-test:\(tag.out)"
|
||||
#up: [
|
||||
op.#DockerLogin & {
|
||||
target: ref
|
||||
registry
|
||||
},
|
||||
op.#WriteFile & {
|
||||
|
Reference in New Issue
Block a user