Merge pull request #101287 from soltysh/replace_with_default

Fail fast when image is specified without tag
This commit is contained in:
Kubernetes Prow Robot 2021-04-20 17:38:24 -07:00 committed by GitHub
commit 6a7572e4ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -73,7 +73,7 @@ spec:
# test for directories or create them. It needs additional privileges
# for that.
- name: busybox
image: k8s.gcr.io/busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29-1
securityContext:
privileged: true
command:

View File

@ -373,6 +373,9 @@ func ReplaceRegistryInImageURL(imageURL string) (string, error) {
}
}
last := strings.SplitN(parts[countParts-1], ":", 2)
if len(last) == 1 {
return "", fmt.Errorf("image %q is required to be in an image:tag format", imageURL)
}
config := getRepositoryMappedConfig(index, Config{
registry: parts[0],
name: strings.Join([]string{strings.Join(parts[1:countParts-1], "/"), last[0]}, "/"),
@ -384,6 +387,8 @@ func ReplaceRegistryInImageURL(imageURL string) (string, error) {
switch registryAndUser {
case "gcr.io/kubernetes-e2e-test-images":
registryAndUser = e2eRegistry
case "k8s.gcr.io/e2e-test-images":
registryAndUser = promoterE2eRegistry
case "k8s.gcr.io":
registryAndUser = gcRegistry
case "k8s.gcr.io/sig-storage":