-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cherry-pick: fix for private registries in test workflows (#5400)
* fix issue with image pull secrets for workflows due to invalid registry append (#5397) * fix issue with image pull secrets for workflows (#5378)
- Loading branch information
Showing
5 changed files
with
69 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package imageinspector | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestExtractRegistry uses table-driven tests to validate the extractRegistry function. | ||
func TestExtractRegistry(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
image string | ||
expected string | ||
}{ | ||
{"DockerHub short", "nginx:latest", "https://index.docker.io/v1/"}, | ||
{"DockerHub long", "library/nginx:latest", "https://index.docker.io/v1/"}, | ||
{"GCR", "gcr.io/google-containers/busybox:latest", "gcr.io"}, | ||
{"ECR", "123456789012.dkr.ecr.us-east-1.amazonaws.com/my-application:latest", "123456789012.dkr.ecr.us-east-1.amazonaws.com"}, | ||
{"MCR", "mcr.microsoft.com/dotnet/core/sdk:3.1", "mcr.microsoft.com"}, | ||
{"Quay", "quay.io/bitnami/nginx:latest", "quay.io"}, | ||
{"Custom port", "localhost:5000/myimage:latest", "localhost:5000"}, | ||
{"No tag", "myregistry.com/myimage", "myregistry.com"}, | ||
{"Only image", "myimage", "https://index.docker.io/v1/"}, | ||
{"Custom GitLab", "registry.gitlab.com/company/base-docker-images/ubuntu-python-base-image:3.12.0-jammy", "registry.gitlab.com"}, | ||
} | ||
|
||
for _, tc := range tests { | ||
tc := tc | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := extractRegistry(tc.image) | ||
assert.Equal(t, tc.expected, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package utils | ||
|
||
const ( | ||
// DefaultDockerRegistry is the default registry used when no registry is specified in the image name. | ||
DefaultDockerRegistry = "https://index.docker.io/v1/" | ||
) |