@@ -923,22 +923,20 @@ passwd:
923923
924924 tmpFile , err := os .CreateTemp ("" , "ignition-template-*.yaml" )
925925 Expect (err ).NotTo (HaveOccurred ())
926- defer func () {
927- Expect (os .Remove (tmpFile .Name ())).To (Succeed ())
928- }()
926+ DeferCleanup (os .Remove , tmpFile .Name ())
929927
930928 _ , err = tmpFile .WriteString (customTemplate )
931929 Expect (err ).NotTo (HaveOccurred ())
932930 Expect (tmpFile .Close ()).To (Succeed ())
933931
934932 By ("Creating a ServerReconciler with file path" )
935933 reconciler := & ServerReconciler {
936- Client : k8sClient ,
937- Scheme : k8sClient .Scheme (),
938- RegistryURL : registryURL ,
939- ManagerNamespace : ns .Name ,
940- ProbeImage : "foo:latest" ,
941- IgnitionConfigPath : tmpFile .Name (),
934+ Client : k8sClient ,
935+ Scheme : k8sClient .Scheme (),
936+ RegistryURL : registryURL ,
937+ ManagerNamespace : ns .Name ,
938+ ProbeImage : "foo:latest" ,
939+ DiscoveryIgnitionPath : tmpFile .Name (),
942940 }
943941
944942 By ("Generating ignition data with custom file" )
@@ -961,12 +959,12 @@ passwd:
961959 It ("Should fallback with error when file is missing" , func (ctx SpecContext ) {
962960 By ("Creating a ServerReconciler with non-existent file path" )
963961 reconciler := & ServerReconciler {
964- Client : k8sClient ,
965- Scheme : k8sClient .Scheme (),
966- RegistryURL : registryURL ,
967- ManagerNamespace : ns .Name ,
968- ProbeImage : "foo:latest" ,
969- IgnitionConfigPath : "/nonexistent/path/ignition.yaml" ,
962+ Client : k8sClient ,
963+ Scheme : k8sClient .Scheme (),
964+ RegistryURL : registryURL ,
965+ ManagerNamespace : ns .Name ,
966+ ProbeImage : "foo:latest" ,
967+ DiscoveryIgnitionPath : "/nonexistent/path/ignition.yaml" ,
970968 }
971969
972970 By ("Generating ignition data (should fail)" )
@@ -989,22 +987,20 @@ systemd:
989987
990988 tmpFile , err := os .CreateTemp ("" , "invalid-template-*.yaml" )
991989 Expect (err ).NotTo (HaveOccurred ())
992- defer func () {
993- Expect (os .Remove (tmpFile .Name ())).To (Succeed ())
994- }()
990+ DeferCleanup (os .Remove , tmpFile .Name ())
995991
996992 _ , err = tmpFile .WriteString (invalidTemplate )
997993 Expect (err ).NotTo (HaveOccurred ())
998994 Expect (tmpFile .Close ()).To (Succeed ())
999995
1000996 By ("Creating a ServerReconciler with invalid template file" )
1001997 reconciler := & ServerReconciler {
1002- Client : k8sClient ,
1003- Scheme : k8sClient .Scheme (),
1004- RegistryURL : registryURL ,
1005- ManagerNamespace : ns .Name ,
1006- ProbeImage : "foo:latest" ,
1007- IgnitionConfigPath : tmpFile .Name (),
998+ Client : k8sClient ,
999+ Scheme : k8sClient .Scheme (),
1000+ RegistryURL : registryURL ,
1001+ ManagerNamespace : ns .Name ,
1002+ ProbeImage : "foo:latest" ,
1003+ DiscoveryIgnitionPath : tmpFile .Name (),
10081004 }
10091005
10101006 By ("Generating ignition data (should fail)" )
@@ -1040,22 +1036,20 @@ passwd:
10401036
10411037 tmpFile , err := os .CreateTemp ("" , "default-ignition-*.yaml" )
10421038 Expect (err ).NotTo (HaveOccurred ())
1043- defer func () {
1044- Expect (os .Remove (tmpFile .Name ())).To (Succeed ())
1045- }()
1039+ DeferCleanup (os .Remove , tmpFile .Name ())
10461040
10471041 _ , err = tmpFile .WriteString (defaultTemplate )
10481042 Expect (err ).NotTo (HaveOccurred ())
10491043 Expect (tmpFile .Close ()).To (Succeed ())
10501044
10511045 By ("Creating a ServerReconciler with default file path" )
10521046 reconciler := & ServerReconciler {
1053- Client : k8sClient ,
1054- Scheme : k8sClient .Scheme (),
1055- RegistryURL : registryURL ,
1056- ManagerNamespace : ns .Name ,
1057- ProbeImage : "foo:latest" ,
1058- IgnitionConfigPath : tmpFile .Name (),
1047+ Client : k8sClient ,
1048+ Scheme : k8sClient .Scheme (),
1049+ RegistryURL : registryURL ,
1050+ ManagerNamespace : ns .Name ,
1051+ ProbeImage : "foo:latest" ,
1052+ DiscoveryIgnitionPath : tmpFile .Name (),
10591053 }
10601054
10611055 By ("Generating ignition data (should use default template)" )
@@ -1098,23 +1092,21 @@ passwd:
10981092
10991093 tmpFile , err := os .CreateTemp ("" , "e2e-ignition-*.yaml" )
11001094 Expect (err ).NotTo (HaveOccurred ())
1101- defer func () {
1102- Expect (os .Remove (tmpFile .Name ())).To (Succeed ())
1103- }()
1095+ DeferCleanup (os .Remove , tmpFile .Name ())
11041096
11051097 _ , err = tmpFile .WriteString (customTemplate )
11061098 Expect (err ).NotTo (HaveOccurred ())
11071099 Expect (tmpFile .Close ()).To (Succeed ())
11081100
11091101 By ("Creating a reconciler with custom ignition template path" )
11101102 customReconciler := & ServerReconciler {
1111- Client : k8sClient ,
1112- Scheme : k8sClient .Scheme (),
1113- RegistryURL : registryURL ,
1114- ManagerNamespace : ns .Name ,
1115- ProbeImage : "custom-probe:v1.0.0" ,
1116- Insecure : true ,
1117- IgnitionConfigPath : tmpFile .Name (),
1103+ Client : k8sClient ,
1104+ Scheme : k8sClient .Scheme (),
1105+ RegistryURL : registryURL ,
1106+ ManagerNamespace : ns .Name ,
1107+ ProbeImage : "custom-probe:v1.0.0" ,
1108+ Insecure : true ,
1109+ DiscoveryIgnitionPath : tmpFile .Name (),
11181110 }
11191111
11201112 By ("Generating ignition data with custom template" )
0 commit comments