@@ -20,6 +20,7 @@ import (
20
20
"fmt"
21
21
"io/ioutil"
22
22
"os"
23
+ "strings"
23
24
24
25
yaml "gopkg.in/yaml.v2"
25
26
)
@@ -31,9 +32,11 @@ type RegistryList struct {
31
32
E2eRegistry string `yaml:"e2eRegistry"`
32
33
InvalidRegistry string `yaml:"invalidRegistry"`
33
34
GcRegistry string `yaml:"gcRegistry"`
35
+ GcrReleaseRegistry string `yaml:"gcrReleaseRegistry"`
34
36
GoogleContainerRegistry string `yaml:"googleContainerRegistry"`
35
37
PrivateRegistry string `yaml:"privateRegistry"`
36
38
SampleRegistry string `yaml:"sampleRegistry"`
39
+ QuayK8sCSI string `yaml:"quayK8sCSI"`
37
40
}
38
41
39
42
// Config holds an images registry, name, and version
@@ -65,9 +68,11 @@ func initReg() RegistryList {
65
68
E2eRegistry : "gcr.io/kubernetes-e2e-test-images" ,
66
69
InvalidRegistry : "invalid.com/invalid" ,
67
70
GcRegistry : "k8s.gcr.io" ,
71
+ GcrReleaseRegistry : "gcr.io/gke-release" ,
68
72
GoogleContainerRegistry : "gcr.io/google-containers" ,
69
73
PrivateRegistry : "gcr.io/k8s-authenticated-test" ,
70
74
SampleRegistry : "gcr.io/google-samples" ,
75
+ QuayK8sCSI : "quay.io/k8scsi" ,
71
76
}
72
77
repoList := os .Getenv ("KUBE_TEST_REPO_LIST" )
73
78
if repoList == "" {
93
98
e2eGcRegistry = "gcr.io/kubernetes-e2e-test-images"
94
99
gcAuthenticatedRegistry = registry .GcAuthenticatedRegistry
95
100
gcRegistry = registry .GcRegistry
101
+ gcrReleaseRegistry = registry .GcrReleaseRegistry
96
102
googleContainerRegistry = registry .GoogleContainerRegistry
97
103
invalidRegistry = registry .InvalidRegistry
104
+ quayK8sCSI = registry .QuayK8sCSI
98
105
// PrivateRegistry is an image repository that requires authentication
99
106
PrivateRegistry = registry .PrivateRegistry
100
107
sampleRegistry = registry .SampleRegistry
@@ -269,3 +276,38 @@ func (i *Config) GetE2EImage() string {
269
276
func GetPauseImageName () string {
270
277
return GetE2EImage (Pause )
271
278
}
279
+
280
+ // ReplaceRegistryInImageURL replaces the registry in the image URL with a custom one
281
+ func ReplaceRegistryInImageURL (imageURL string ) (string , error ) {
282
+ parts := strings .Split (imageURL , "/" )
283
+ countParts := len (parts )
284
+ registryAndUser := strings .Join (parts [:countParts - 1 ], "/" )
285
+
286
+ switch registryAndUser {
287
+ case "gcr.io/kubernetes-e2e-test-images" :
288
+ registryAndUser = e2eRegistry
289
+ case "k8s.gcr.io" :
290
+ registryAndUser = gcRegistry
291
+ case "gcr.io/k8s-authenticated-test" :
292
+ registryAndUser = PrivateRegistry
293
+ case "gcr.io/google-samples" :
294
+ registryAndUser = sampleRegistry
295
+ case "gcr.io/gke-release" :
296
+ registryAndUser = gcrReleaseRegistry
297
+ case "docker.io/library" :
298
+ registryAndUser = dockerLibraryRegistry
299
+ case "quay.io/k8scsi" :
300
+ registryAndUser = quayK8sCSI
301
+ default :
302
+ if countParts == 1 {
303
+ // We assume we found an image from docker hub library
304
+ // e.g. openjdk -> docker.io/library/openjdk
305
+ registryAndUser = dockerLibraryRegistry
306
+ break
307
+ }
308
+
309
+ return "" , fmt .Errorf ("Registry: %s is missing in test/utils/image/manifest.go, please add the registry, otherwise the test will fail on air-gapped clusters" , registryAndUser )
310
+ }
311
+
312
+ return fmt .Sprintf ("%s/%s" , registryAndUser , parts [countParts - 1 ]), nil
313
+ }
0 commit comments