2
2
* IBM Confidential
3
3
* OCO Source Materials
4
4
* 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.
6
6
* The source code for this program is not published or otherwise divested of
7
7
* its trade secrets, irrespective of what has been deposited with
8
8
* the U.S. Copyright Office.
@@ -12,7 +12,6 @@ package crn
12
12
13
13
import (
14
14
"fmt"
15
- "io/ioutil"
16
15
"os"
17
16
"path/filepath"
18
17
"testing"
@@ -68,7 +67,7 @@ func TestGetServiceCRNError(t *testing.T) {
68
67
fullPath := testPathDirectory + "/" + CRNCnameProp
69
68
cleanupConfigMapMount (fullPath )
70
69
valueAsByteArray := []byte (CRNCnameProp )
71
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
70
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
72
71
testCM , err := GetServiceCRN ()
73
72
assert .Nil (t , err )
74
73
assert .Equal (t , testCM , expectedCRNString )
@@ -103,7 +102,7 @@ func TestGetCRNValueFromConfigMapMount(t *testing.T) {
103
102
// make sure this file isn't already hanging out
104
103
os .Remove (testFile )
105
104
cnameValue := []byte (testValue )
106
- err := ioutil .WriteFile (testFile , cnameValue , 0644 )
105
+ err := os .WriteFile (testFile , cnameValue , 0644 )
107
106
assert .Nil (t , err , "Error writing config map volume file." )
108
107
expected := testValue
109
108
defaultValue := "testDefault"
@@ -163,7 +162,7 @@ func TestGetServiceCRNStructCNameError(t *testing.T) {
163
162
fullPath := testPathDirectory + "/" + CRNCnameProp
164
163
cleanupConfigMapMount (fullPath )
165
164
valueAsByteArray := []byte (CRNCnameProp )
166
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
165
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
167
166
_ , err := GetServiceCRNStruct (testPathDirectory )
168
167
assert .Error (t , err )
169
168
cleanupConfigMapMount (fullPath )
@@ -173,14 +172,14 @@ func TestGetServiceCRNStructCVersionError(t *testing.T) {
173
172
fullPath := testPathDirectory + "/" + CRNCnameProp
174
173
cleanupConfigMapMount (fullPath )
175
174
valueAsByteArray := []byte (CRNCnameProp )
176
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
175
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
177
176
_ , err := GetServiceCRNStruct (testPathDirectory )
178
177
assert .Nil (t , err )
179
178
180
179
fullPath = testPathDirectory + "/" + CRNVersionProp
181
180
cleanupConfigMapMount (fullPath )
182
181
valueAsByteArray = []byte (CRNVersionProp )
183
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
182
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
184
183
_ , err = GetServiceCRNStruct (testPathDirectory )
185
184
assert .Error (t , err )
186
185
cleanupConfigMapMount (fullPath )
@@ -190,21 +189,21 @@ func TestGetServiceCRNStructCTypeError(t *testing.T) {
190
189
fullPath := testPathDirectory + "/" + CRNCnameProp
191
190
cleanupConfigMapMount (fullPath )
192
191
valueAsByteArray := []byte (CRNCnameProp )
193
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
192
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
194
193
_ , err := GetServiceCRNStruct (testPathDirectory )
195
194
assert .Nil (t , err )
196
195
197
196
fullPath = testPathDirectory + "/" + CRNVersionProp
198
197
cleanupConfigMapMount (fullPath )
199
198
valueAsByteArray = []byte (CRNVersionProp )
200
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
199
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
201
200
_ , err = GetServiceCRNStruct (testPathDirectory )
202
201
assert .Nil (t , err )
203
202
204
203
fullPath = testPathDirectory + "/" + CRNCtypeProp
205
204
cleanupConfigMapMount (fullPath )
206
205
valueAsByteArray = []byte (CRNCtypeProp )
207
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
206
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
208
207
_ , err = GetServiceCRNStruct (testPathDirectory )
209
208
assert .Error (t , err )
210
209
cleanupConfigMapMount (fullPath )
@@ -215,7 +214,7 @@ func TestGetServiceCRNStructVersionError(t *testing.T) {
215
214
fullPath := testPathDirectory + "/" + CRNCnameProp
216
215
cleanupConfigMapMount (fullPath )
217
216
valueAsByteArray := []byte (CRNCnameProp )
218
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
217
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
219
218
_ , err := GetServiceCRNStruct (testPathDirectory )
220
219
assert .Error (t , err )
221
220
}
@@ -224,28 +223,28 @@ func TestGetServiceCRNStructCRegionError(t *testing.T) {
224
223
fullPath := testPathDirectory + "/" + CRNCnameProp
225
224
cleanupConfigMapMount (fullPath )
226
225
valueAsByteArray := []byte (CRNCnameProp )
227
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
226
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
228
227
_ , err := GetServiceCRNStruct (testPathDirectory )
229
228
assert .Nil (t , err )
230
229
231
230
fullPath = testPathDirectory + "/" + CRNVersionProp
232
231
cleanupConfigMapMount (fullPath )
233
232
valueAsByteArray = []byte (CRNVersionProp )
234
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
233
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
235
234
_ , err = GetServiceCRNStruct (testPathDirectory )
236
235
assert .Nil (t , err )
237
236
238
237
fullPath = testPathDirectory + "/" + CRNCtypeProp
239
238
cleanupConfigMapMount (fullPath )
240
239
valueAsByteArray = []byte (CRNCtypeProp )
241
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
240
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
242
241
_ , err = GetServiceCRNStruct (testPathDirectory )
243
242
assert .Nil (t , err )
244
243
245
244
fullPath = testPathDirectory + "/" + CRNRegionProp
246
245
cleanupConfigMapMount (fullPath )
247
246
valueAsByteArray = []byte (CRNRegionProp )
248
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
247
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
249
248
_ , err = GetServiceCRNStruct (testPathDirectory )
250
249
assert .Error (t , err )
251
250
cleanupConfigMapMount (fullPath )
@@ -255,42 +254,42 @@ func TestGetServiceCRNStructCServiceNameError(t *testing.T) {
255
254
fullPath := testPathDirectory + "/" + CRNCnameProp
256
255
cleanupConfigMapMount (fullPath )
257
256
valueAsByteArray := []byte (CRNCnameProp )
258
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
257
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
259
258
_ , err := GetServiceCRNStruct (testPathDirectory )
260
259
assert .Nil (t , err )
261
260
262
261
fullPath = testPathDirectory + "/" + CRNVersionProp
263
262
cleanupConfigMapMount (fullPath )
264
263
valueAsByteArray = []byte (CRNVersionProp )
265
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
264
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
266
265
_ , err = GetServiceCRNStruct (testPathDirectory )
267
266
assert .Nil (t , err )
268
267
269
268
fullPath = testPathDirectory + "/" + CRNCtypeProp
270
269
cleanupConfigMapMount (fullPath )
271
270
valueAsByteArray = []byte (CRNCtypeProp )
272
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
271
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
273
272
_ , err = GetServiceCRNStruct (testPathDirectory )
274
273
assert .Nil (t , err )
275
274
276
275
fullPath = testPathDirectory + "/" + CRNRegionProp
277
276
cleanupConfigMapMount (fullPath )
278
277
valueAsByteArray = []byte (CRNRegionProp )
279
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
278
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
280
279
_ , err = GetServiceCRNStruct (testPathDirectory )
281
280
assert .Nil (t , err )
282
281
283
282
fullPath = testPathDirectory + "/" + CRNClusterIDProp
284
283
cleanupConfigMapMount (fullPath )
285
284
valueAsByteArray = []byte (CRNClusterIDProp )
286
- ioutil .WriteFile (fullPath , valueAsByteArray , 0777 )
285
+ os .WriteFile (fullPath , valueAsByteArray , 0777 )
287
286
_ , err = GetServiceCRNStruct (testPathDirectory )
288
287
assert .Nil (t , err )
289
288
290
289
fullPath = testPathDirectory + "/" + CRNServiceNameProp
291
290
cleanupConfigMapMount (fullPath )
292
291
valueAsByteArray = []byte (CRNServiceNameProp )
293
- ioutil .WriteFile (fullPath , valueAsByteArray , 0000 )
292
+ os .WriteFile (fullPath , valueAsByteArray , 0000 )
294
293
_ , err = GetServiceCRNStruct (testPathDirectory )
295
294
assert .Error (t , err )
296
295
cleanupConfigMapMount (fullPath )
@@ -299,7 +298,7 @@ func TestGetServiceCRNStructCServiceNameError(t *testing.T) {
299
298
func prepConfigMapMount (fileName string , value string ) error {
300
299
cleanupConfigMapMount (fileName )
301
300
valueAsByteArray := []byte (value )
302
- return ioutil .WriteFile (fileName , valueAsByteArray , 0644 )
301
+ return os .WriteFile (fileName , valueAsByteArray , 0644 )
303
302
}
304
303
305
304
func cleanupConfigMapMount (filename string ) {
0 commit comments