From 174ad83af79df3c23d1ae02c54ea074065e06701 Mon Sep 17 00:00:00 2001 From: Zachary Rollyson Date: Mon, 29 Jul 2024 13:07:41 -0400 Subject: [PATCH] Whitespace & comments for get_reg_credentials legibility --- runner/cf-driver/prepare.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runner/cf-driver/prepare.sh b/runner/cf-driver/prepare.sh index 3860862..c186a8c 100755 --- a/runner/cf-driver/prepare.sh +++ b/runner/cf-driver/prepare.sh @@ -31,11 +31,22 @@ create_temporary_varfile () { get_registry_credentials () { image_name="$1" + # Note: the regex for non-docker image locations is not air-tight-- + # the definition for the format is a little loose, for one thing, + # but this should work for most cases and can be revisited when + # we're working with more a more robust set of language features + # and can better parse the image name. + if echo "$image_name" | grep -q "registry.gitlab.com"; then + # Detect GitLab CR and use provided environment to authenticate echo "$CUSTOM_ENV_CI_REGISTRY_USER" "$CUSTOM_ENV_CI_REGISTRY_PASSWORD" + elif echo "$image_name" | grep -q -P '^(?!registry-\d+.docker.io)[\w-]+(?:\.[\w-]+)+'; then + # Detect non-Docker registry that we aren't supporting auth for yet return 0 + elif [ -n "$DOCKER_HUB_TOKEN" ] && [ -n "$DOCKER_HUB_USER" ]; then + # Default to Docker Hub credentials when available echo "$DOCKER_HUB_USER" "$DOCKER_HUB_TOKEN" fi }