Improve parseAuthHost function to work for all ref
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
d10f2a49a5
commit
58a67cf86b
@ -64,17 +64,17 @@ func (a *RegistryAuthProvider) Credentials(ctx context.Context, req *bkauth.Cred
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseAuthHost(host string) (*url.URL, error) {
|
func parseAuthHost(host string) (*url.URL, error) {
|
||||||
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") && strings.Contains(host, "/") {
|
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)
|
ref, err := reference.ParseNormalizedNamed(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
host = ref.String()
|
host = ref.String()
|
||||||
}
|
|
||||||
|
|
||||||
if strings.Contains(host, "docker.io") {
|
|
||||||
host = "https://index.docker.io/v1/"
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
|
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
|
||||||
host = "https://" + host
|
host = "https://" + host
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
setup() {
|
|
||||||
load 'helpers'
|
|
||||||
|
|
||||||
common_setup
|
|
||||||
}
|
|
||||||
|
|
||||||
# FIXME: move to universe/universe.bats
|
|
||||||
# Assigned to: <ADD YOUR NAME HERE>
|
|
||||||
# Changes in https://github.com/dagger/dagger/pull/628
|
|
||||||
@test "stdlib: docker: push-and-pull" {
|
|
||||||
skip_unless_secrets_available "$TESTDIR"/stdlib/docker/push-pull/inputs.yaml
|
|
||||||
|
|
||||||
# check that they succeed with the credentials
|
|
||||||
run "$DAGGER" compute --input-yaml "$TESTDIR"/stdlib/docker/push-pull/inputs.yaml --input-dir source="$TESTDIR"/stdlib/docker/push-pull/testdata "$TESTDIR"/stdlib/docker/push-pull/
|
|
||||||
assert_success
|
|
||||||
}
|
|
Reference in New Issue
Block a user