From 77b55c82e2ed42b7bb1b9d459a77602d5d8de3a0 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Mon, 11 Apr 2022 00:21:48 +0200 Subject: [PATCH] Further check host values after parsing If any of the hosts is empty at this point, something has gone wrong. --- pkg/credhelper/credhelper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/credhelper/credhelper.go b/pkg/credhelper/credhelper.go index 7f851c8..800e393 100644 --- a/pkg/credhelper/credhelper.go +++ b/pkg/credhelper/credhelper.go @@ -63,6 +63,9 @@ func matchRegistryURL(serverURLString string) error { if err != nil { return fmt.Errorf("failed to parse registry URL: %w", err) } + if serverURL.Hostname() == "" || envURL.Hostname() == "" { + return errors.New("failed getting hosts for matching") + } if serverURL.Hostname() != envURL.Hostname() { return fmt.Errorf("host '%s' does not match CI_REGISTRY host '%s'", serverURL.Hostname(),