22 * IBM Confidential
33 * OCO Source Materials
44 * IBM Cloud Kubernetes Service, 5737-D43
5- * (C) Copyright IBM Corp. 2022 All Rights Reserved.
5+ * (C) Copyright IBM Corp. 2022, 2024 All Rights Reserved.
66 * The source code for this program is not published or otherwise divested of
77 * its trade secrets, irrespective of what has been deposited with
88 * the U.S. Copyright Office.
@@ -12,7 +12,6 @@ package crn
1212
1313import (
1414 "fmt"
15- "io/ioutil"
1615 "os"
1716 "path/filepath"
1817 "testing"
@@ -68,7 +67,7 @@ func TestGetServiceCRNError(t *testing.T) {
6867 fullPath := testPathDirectory + "/" + CRNCnameProp
6968 cleanupConfigMapMount (fullPath )
7069 valueAsByteArray := []byte (CRNCnameProp )
71- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
70+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
7271 testCM , err := GetServiceCRN ()
7372 assert .Nil (t , err )
7473 assert .Equal (t , testCM , expectedCRNString )
@@ -103,7 +102,7 @@ func TestGetCRNValueFromConfigMapMount(t *testing.T) {
103102 // make sure this file isn't already hanging out
104103 os .Remove (testFile )
105104 cnameValue := []byte (testValue )
106- err := ioutil .WriteFile (testFile , cnameValue , 0644 )
105+ err := os .WriteFile (testFile , cnameValue , 0644 )
107106 assert .Nil (t , err , "Error writing config map volume file." )
108107 expected := testValue
109108 defaultValue := "testDefault"
@@ -163,7 +162,7 @@ func TestGetServiceCRNStructCNameError(t *testing.T) {
163162 fullPath := testPathDirectory + "/" + CRNCnameProp
164163 cleanupConfigMapMount (fullPath )
165164 valueAsByteArray := []byte (CRNCnameProp )
166- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
165+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
167166 _ , err := GetServiceCRNStruct (testPathDirectory )
168167 assert .Error (t , err )
169168 cleanupConfigMapMount (fullPath )
@@ -173,14 +172,14 @@ func TestGetServiceCRNStructCVersionError(t *testing.T) {
173172 fullPath := testPathDirectory + "/" + CRNCnameProp
174173 cleanupConfigMapMount (fullPath )
175174 valueAsByteArray := []byte (CRNCnameProp )
176- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
175+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
177176 _ , err := GetServiceCRNStruct (testPathDirectory )
178177 assert .Nil (t , err )
179178
180179 fullPath = testPathDirectory + "/" + CRNVersionProp
181180 cleanupConfigMapMount (fullPath )
182181 valueAsByteArray = []byte (CRNVersionProp )
183- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
182+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
184183 _ , err = GetServiceCRNStruct (testPathDirectory )
185184 assert .Error (t , err )
186185 cleanupConfigMapMount (fullPath )
@@ -190,21 +189,21 @@ func TestGetServiceCRNStructCTypeError(t *testing.T) {
190189 fullPath := testPathDirectory + "/" + CRNCnameProp
191190 cleanupConfigMapMount (fullPath )
192191 valueAsByteArray := []byte (CRNCnameProp )
193- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
192+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
194193 _ , err := GetServiceCRNStruct (testPathDirectory )
195194 assert .Nil (t , err )
196195
197196 fullPath = testPathDirectory + "/" + CRNVersionProp
198197 cleanupConfigMapMount (fullPath )
199198 valueAsByteArray = []byte (CRNVersionProp )
200- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
199+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
201200 _ , err = GetServiceCRNStruct (testPathDirectory )
202201 assert .Nil (t , err )
203202
204203 fullPath = testPathDirectory + "/" + CRNCtypeProp
205204 cleanupConfigMapMount (fullPath )
206205 valueAsByteArray = []byte (CRNCtypeProp )
207- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
206+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
208207 _ , err = GetServiceCRNStruct (testPathDirectory )
209208 assert .Error (t , err )
210209 cleanupConfigMapMount (fullPath )
@@ -215,7 +214,7 @@ func TestGetServiceCRNStructVersionError(t *testing.T) {
215214 fullPath := testPathDirectory + "/" + CRNCnameProp
216215 cleanupConfigMapMount (fullPath )
217216 valueAsByteArray := []byte (CRNCnameProp )
218- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
217+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
219218 _ , err := GetServiceCRNStruct (testPathDirectory )
220219 assert .Error (t , err )
221220}
@@ -224,28 +223,28 @@ func TestGetServiceCRNStructCRegionError(t *testing.T) {
224223 fullPath := testPathDirectory + "/" + CRNCnameProp
225224 cleanupConfigMapMount (fullPath )
226225 valueAsByteArray := []byte (CRNCnameProp )
227- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
226+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
228227 _ , err := GetServiceCRNStruct (testPathDirectory )
229228 assert .Nil (t , err )
230229
231230 fullPath = testPathDirectory + "/" + CRNVersionProp
232231 cleanupConfigMapMount (fullPath )
233232 valueAsByteArray = []byte (CRNVersionProp )
234- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
233+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
235234 _ , err = GetServiceCRNStruct (testPathDirectory )
236235 assert .Nil (t , err )
237236
238237 fullPath = testPathDirectory + "/" + CRNCtypeProp
239238 cleanupConfigMapMount (fullPath )
240239 valueAsByteArray = []byte (CRNCtypeProp )
241- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
240+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
242241 _ , err = GetServiceCRNStruct (testPathDirectory )
243242 assert .Nil (t , err )
244243
245244 fullPath = testPathDirectory + "/" + CRNRegionProp
246245 cleanupConfigMapMount (fullPath )
247246 valueAsByteArray = []byte (CRNRegionProp )
248- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
247+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
249248 _ , err = GetServiceCRNStruct (testPathDirectory )
250249 assert .Error (t , err )
251250 cleanupConfigMapMount (fullPath )
@@ -255,42 +254,42 @@ func TestGetServiceCRNStructCServiceNameError(t *testing.T) {
255254 fullPath := testPathDirectory + "/" + CRNCnameProp
256255 cleanupConfigMapMount (fullPath )
257256 valueAsByteArray := []byte (CRNCnameProp )
258- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
257+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
259258 _ , err := GetServiceCRNStruct (testPathDirectory )
260259 assert .Nil (t , err )
261260
262261 fullPath = testPathDirectory + "/" + CRNVersionProp
263262 cleanupConfigMapMount (fullPath )
264263 valueAsByteArray = []byte (CRNVersionProp )
265- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
264+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
266265 _ , err = GetServiceCRNStruct (testPathDirectory )
267266 assert .Nil (t , err )
268267
269268 fullPath = testPathDirectory + "/" + CRNCtypeProp
270269 cleanupConfigMapMount (fullPath )
271270 valueAsByteArray = []byte (CRNCtypeProp )
272- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
271+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
273272 _ , err = GetServiceCRNStruct (testPathDirectory )
274273 assert .Nil (t , err )
275274
276275 fullPath = testPathDirectory + "/" + CRNRegionProp
277276 cleanupConfigMapMount (fullPath )
278277 valueAsByteArray = []byte (CRNRegionProp )
279- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
278+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
280279 _ , err = GetServiceCRNStruct (testPathDirectory )
281280 assert .Nil (t , err )
282281
283282 fullPath = testPathDirectory + "/" + CRNClusterIDProp
284283 cleanupConfigMapMount (fullPath )
285284 valueAsByteArray = []byte (CRNClusterIDProp )
286- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
285+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
287286 _ , err = GetServiceCRNStruct (testPathDirectory )
288287 assert .Nil (t , err )
289288
290289 fullPath = testPathDirectory + "/" + CRNServiceNameProp
291290 cleanupConfigMapMount (fullPath )
292291 valueAsByteArray = []byte (CRNServiceNameProp )
293- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
292+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
294293 _ , err = GetServiceCRNStruct (testPathDirectory )
295294 assert .Error (t , err )
296295 cleanupConfigMapMount (fullPath )
@@ -299,7 +298,7 @@ func TestGetServiceCRNStructCServiceNameError(t *testing.T) {
299298func prepConfigMapMount (fileName string , value string ) error {
300299 cleanupConfigMapMount (fileName )
301300 valueAsByteArray := []byte (value )
302- return ioutil .WriteFile (fileName , valueAsByteArray , 0644 )
301+ return os .WriteFile (fileName , valueAsByteArray , 0644 )
303302}
304303
305304func cleanupConfigMapMount (filename string ) {
0 commit comments