@@ -1011,3 +1011,88 @@ func makePerformanceProfileStatusAsString(opts ...func(*performanceprofilev2.Per
1011
1011
b , _ := yaml .Marshal (status )
1012
1012
return string (b )
1013
1013
}
1014
+
1015
+ func TestGetMirrorConfigForManifest (t * testing.T ) {
1016
+ machineConfig := `
1017
+ apiVersion: machineconfiguration.openshift.io/v1
1018
+ kind: MachineConfig
1019
+ metadata:
1020
+ labels:
1021
+ machineconfiguration.openshift.io/role: worker
1022
+ name: valid-machineconfig
1023
+ spec:
1024
+ config:
1025
+ ignition:
1026
+ version: 2.2.0
1027
+ storage:
1028
+ files:
1029
+ - contents:
1030
+ source: data:text/plain;base64,dGhyb3dhd2F5Cg==
1031
+ filesystem: root
1032
+ mode: 493
1033
+ path: /some/path
1034
+ `
1035
+
1036
+ containerRuntimeConfig := `
1037
+ apiVersion: machineconfiguration.openshift.io/v1
1038
+ kind: ContainerRuntimeConfig
1039
+ metadata:
1040
+ name: valid-containerruntimeconfig
1041
+ spec:
1042
+ containerRuntimeConfig:
1043
+ defaultRuntime: crun
1044
+ `
1045
+
1046
+ kubeletConfig := `
1047
+ apiVersion: machineconfiguration.openshift.io/v1
1048
+ kind: KubeletConfig
1049
+ metadata:
1050
+ name: valid-kubeletconfig
1051
+ spec:
1052
+ kubeletConfig:
1053
+ maxPods: 100
1054
+ `
1055
+
1056
+ imageDigestMirrorSet := `
1057
+ apiVersion: config.openshift.io/v1
1058
+ kind: ImageDigestMirrorSet
1059
+ metadata:
1060
+ name: valid-idms
1061
+ spec:
1062
+ imageDigestMirrors:
1063
+ - mirrorSourcePolicy: AllowContactingSource
1064
+ mirrors:
1065
+ - some.registry.io/registry-redhat-io
1066
+ source: registry.redhat.io
1067
+ `
1068
+
1069
+ testCases := []struct {
1070
+ name string
1071
+ input []byte
1072
+ }{
1073
+ {
1074
+ name : "Valid MachineConfig" ,
1075
+ input : []byte (machineConfig ),
1076
+ },
1077
+ {
1078
+ name : "Valid ContainerRuntimeConfig" ,
1079
+ input : []byte (containerRuntimeConfig ),
1080
+ },
1081
+ {
1082
+ name : "Valid KubeletConfig" ,
1083
+ input : []byte (kubeletConfig ),
1084
+ },
1085
+ {
1086
+ name : "Valid ImageDigestMirrorSet" ,
1087
+ input : []byte (imageDigestMirrorSet ),
1088
+ },
1089
+ }
1090
+
1091
+ for _ , tc := range testCases {
1092
+ t .Run (tc .name , func (t * testing.T ) {
1093
+ g := NewWithT (t )
1094
+ _ , err := getMirrorConfigForManifest (tc .input )
1095
+ g .Expect (err ).To (BeNil ())
1096
+ })
1097
+ }
1098
+ }
0 commit comments