File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed
pkg/handlers/generic/mutation
imageregistries/credentials Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,8 @@ func (GlobalImageRegistryMirror) VariableSchema() clusterv1.VariableSchema {
295295 "url" : {
296296 Description : "Registry mirror URL." ,
297297 Type : "string" ,
298+ Format : "uri" ,
299+ Pattern : "^https?://" ,
298300 },
299301 "credentials" : ImageCredentials {}.VariableSchema ().OpenAPIV3Schema ,
300302 },
@@ -320,6 +322,8 @@ func (ImageRegistry) VariableSchema() clusterv1.VariableSchema {
320322 "url" : {
321323 Description : "Registry URL." ,
322324 Type : "string" ,
325+ Format : "uri" ,
326+ Pattern : "^https?://" ,
323327 },
324328 "credentials" : ImageCredentials {}.VariableSchema ().OpenAPIV3Schema ,
325329 },
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ func TestVariableValidation(t *testing.T) {
3636 Vals : v1alpha1.GenericClusterConfig {
3737 ImageRegistries : []v1alpha1.ImageRegistry {
3838 {
39- URL : "http ://a.b.c.example.com" ,
39+ URL : "https ://a.b.c.example.com/a/b/c " ,
4040 Credentials : & v1alpha1.ImageCredentials {
4141 SecretRef : & corev1.ObjectReference {
4242 Name : "a.b.c.example.com-creds" ,
@@ -46,5 +46,27 @@ func TestVariableValidation(t *testing.T) {
4646 },
4747 },
4848 },
49+ capitest.VariableTestDef {
50+ Name : "invalid registry URL" ,
51+ Vals : v1alpha1.GenericClusterConfig {
52+ ImageRegistries : []v1alpha1.ImageRegistry {
53+ {
54+ URL : "unsupportedformat://a.b.c.example.com" ,
55+ },
56+ },
57+ },
58+ ExpectError : true ,
59+ },
60+ capitest.VariableTestDef {
61+ Name : "registry URL without format" ,
62+ Vals : v1alpha1.GenericClusterConfig {
63+ ImageRegistries : []v1alpha1.ImageRegistry {
64+ {
65+ URL : "a.b.c.example.com/a/b/c" ,
66+ },
67+ },
68+ },
69+ ExpectError : true ,
70+ },
4971 )
5072}
Original file line number Diff line number Diff line change @@ -42,5 +42,23 @@ func TestVariableValidation(t *testing.T) {
4242 },
4343 },
4444 },
45+ capitest.VariableTestDef {
46+ Name : "invalid mirror registry URL" ,
47+ Vals : v1alpha1.GenericClusterConfig {
48+ GlobalImageRegistryMirror : & v1alpha1.GlobalImageRegistryMirror {
49+ URL : "unsupportedformat://a.b.c.example.com" ,
50+ },
51+ },
52+ ExpectError : true ,
53+ },
54+ capitest.VariableTestDef {
55+ Name : "registry URL without http(s) format and path" ,
56+ Vals : v1alpha1.GenericClusterConfig {
57+ GlobalImageRegistryMirror : & v1alpha1.GlobalImageRegistryMirror {
58+ URL : "a.b.c.example.com/a/b/c" ,
59+ },
60+ },
61+ ExpectError : true ,
62+ },
4563 )
4664}
You can’t perform that action at this time.
0 commit comments