@@ -205,6 +205,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
205
205
AddressesFromPools * []AddressesFromPool `json:"addressesFromPools,omitempty"`
206
206
Ipv6Primary * bool `json:"ipv6Primary,omitempty"`
207
207
}
208
+ type WorkerKubeletExtraArgs map [string ]string
208
209
209
210
g := NewWithT (t )
210
211
@@ -214,7 +215,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
214
215
variableName string
215
216
expectedNotFoundError bool
216
217
expectedErr bool
217
- object * Network
218
+ object interface {}
218
219
expectedVariableObject interface {}
219
220
}{
220
221
{
@@ -223,7 +224,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
223
224
variableName : "invalid[" ,
224
225
expectedNotFoundError : false ,
225
226
object : & Network {},
226
- expectedVariableObject : Network {},
227
+ expectedVariableObject : & Network {},
227
228
expectedErr : true ,
228
229
},
229
230
{
@@ -232,7 +233,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
232
233
variableName : "notEsists" ,
233
234
expectedNotFoundError : true ,
234
235
object : & Network {},
235
- expectedVariableObject : Network {},
236
+ expectedVariableObject : & Network {},
236
237
expectedErr : true ,
237
238
},
238
239
{
@@ -244,7 +245,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
244
245
variableName : "network" ,
245
246
expectedNotFoundError : false ,
246
247
object : & Network {},
247
- expectedVariableObject : Network {},
248
+ expectedVariableObject : & Network {},
248
249
expectedErr : true ,
249
250
},
250
251
{
@@ -257,7 +258,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
257
258
expectedNotFoundError : false ,
258
259
expectedErr : false ,
259
260
object : & Network {},
260
- expectedVariableObject : Network {
261
+ expectedVariableObject : & Network {
261
262
Ipv6Primary : ptr .To (true ),
262
263
AddressesFromPools : & []AddressesFromPool {
263
264
{
@@ -266,6 +267,23 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
266
267
},
267
268
},
268
269
},
270
+ {
271
+ name : "valid variable with encoded character" ,
272
+ variables : map [string ]apiextensionsv1.JSON {
273
+ // Note: When a user uses `<` in a string in a variable it will be encoded as `\u003c`
274
+ // This is already done by the APIserver and e.g. visible when doing a simple get cluster call.
275
+ // This test case makes sure that variables that contain `<` are unmarshalled correctly.
276
+ "workerKubeletExtraArgs" : {Raw : []byte (`{"eviction-hard":"memory.available\u003c512M,nodefs.available\u003c5%","eviction-soft":"memory.available\u003c1024M,nodefs.available\u003c10%"}` )},
277
+ },
278
+ variableName : "workerKubeletExtraArgs" ,
279
+ expectedNotFoundError : false ,
280
+ expectedErr : false ,
281
+ object : & WorkerKubeletExtraArgs {},
282
+ expectedVariableObject : & WorkerKubeletExtraArgs {
283
+ "eviction-hard" : "memory.available<512M,nodefs.available<5%" ,
284
+ "eviction-soft" : "memory.available<1024M,nodefs.available<10%" ,
285
+ },
286
+ },
269
287
}
270
288
for _ , tt := range tests {
271
289
t .Run (tt .name , func (* testing.T ) {
@@ -278,7 +296,7 @@ func Test_GetVariableObjectWithNestedType(t *testing.T) {
278
296
if tt .expectedNotFoundError {
279
297
g .Expect (IsNotFoundError (err )).To (BeTrue ())
280
298
}
281
- g .Expect (* tt .object ).To (Equal (tt .expectedVariableObject ))
299
+ g .Expect (tt .object ).To (Equal (tt .expectedVariableObject ))
282
300
})
283
301
}
284
302
}
0 commit comments