@@ -17,8 +17,6 @@ import (
1717 "sigs.k8s.io/kind/pkg/exec"
1818)
1919
20- var re = regexp .MustCompile (`(.*?)hostPath: /tmp/idpbuilder-registry-certs.d-.*(.*?)` )
21-
2220func TestGetConfig (t * testing.T ) {
2321
2422 type tc struct {
@@ -35,8 +33,7 @@ func TestGetConfig(t *testing.T) {
3533 port : "8443" ,
3634 registryConfig : []string {},
3735 usePathRouting : false ,
38- expectConfig : `
39- kind: Cluster
36+ expectConfig : `kind: Cluster
4037apiVersion: kind.x-k8s.io/v1alpha4
4138nodes:
4239- role: control-plane
5249 protocol: TCP
5350 extraMounts:
5451 - containerPath: /etc/containerd/certs.d
52+ hostPath: /tmp/idpbuilder-registry-certs.d-\d+
5553containerdConfigPatches:
5654- |-
5755 [plugins."io.containerd.grpc.v1.cri".registry]
@@ -62,8 +60,7 @@ containerdConfigPatches:
6260 port : "8443" ,
6361 registryConfig : []string {"testdata/doesnt-exist.json" , "testdata/empty.json" },
6462 usePathRouting : true ,
65- expectConfig : `
66- kind: Cluster
63+ expectConfig : `kind: Cluster
6764apiVersion: kind.x-k8s.io/v1alpha4
6865nodes:
6966- role: control-plane
7976 protocol: TCP
8077 extraMounts:
8178 - containerPath: /etc/containerd/certs.d
79+ hostPath: /tmp/idpbuilder-registry-certs.d-\d+
8280 - containerPath: /var/lib/kubelet/config.json
8381 hostPath: testdata/empty.json
8482containerdConfigPatches:
@@ -99,9 +97,8 @@ containerdConfigPatches:
9997
10098 cfg , err := cluster .getConfig ()
10199 assert .NoError (t , err )
102- expectStripped := re .ReplaceAllString (c .expectConfig , `$1$2` )
103- cfgStripped := re .ReplaceAllString (string (cfg ), `$1$2` )
104- assert .YAMLEq (t , expectStripped , cfgStripped )
100+ re := regexp .MustCompile ("(?m)" + c .expectConfig )
101+ assert .Regexp (t , re , string (cfg ), "config did not match expected config regexp" )
105102 }
106103}
107104
@@ -120,8 +117,7 @@ func TestExtraPortMappings(t *testing.T) {
120117 t .Errorf ("Error getting kind config: %v" , err )
121118 }
122119
123- expectConfig := `# Kind kubernetes release images https://github.com/kubernetes-sigs/kind/releases
124- kind: Cluster
120+ expectConfig := `kind: Cluster
125121apiVersion: kind.x-k8s.io/v1alpha4
126122nodes:
127123- role: control-plane
@@ -140,14 +136,14 @@ nodes:
140136 protocol: TCP
141137 extraMounts:
142138 - containerPath: /etc/containerd/certs.d
139+ hostPath: /tmp/idpbuilder-registry-certs.d-\d+
143140containerdConfigPatches:
144141- |-
145142 [plugins."io.containerd.grpc.v1.cri".registry]
146143 config_path = "/etc/containerd/certs.d"`
147144
148- expectStripped := re .ReplaceAllString (expectConfig , `$1$2` )
149- cfgStripped := re .ReplaceAllString (string (cfg ), `$1$2` )
150- assert .YAMLEq (t , expectStripped , cfgStripped )
145+ re := regexp .MustCompile ("(?m)" + expectConfig )
146+ assert .Regexp (t , re , string (cfg ), "config did not match expected config regexp" )
151147}
152148
153149func TestGetConfigCustom (t * testing.T ) {
0 commit comments