mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Dont output nil; test nil & omitempty
This commit is contained in:
parent
edfaa480cf
commit
6c32e071f4
@ -74,7 +74,13 @@ func addParam(values url.Values, tag string, omitempty bool, value reflect.Value
|
|||||||
if omitempty && zeroValue(value) {
|
if omitempty && zeroValue(value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
values.Add(tag, fmt.Sprintf("%v", value.Interface()))
|
val := ""
|
||||||
|
iValue := fmt.Sprintf("%v", value.Interface())
|
||||||
|
|
||||||
|
if iValue != "<nil>" {
|
||||||
|
val = iValue
|
||||||
|
}
|
||||||
|
values.Add(tag, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addListOfParams(values url.Values, tag string, omitempty bool, list reflect.Value) {
|
func addListOfParams(values url.Values, tag string, omitempty bool, list reflect.Value) {
|
||||||
|
@ -151,6 +151,12 @@ func TestConvert(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: url.Values{"ptr": {"<nil>"}, "bptr": {"true"}},
|
expected: url.Values{"ptr": {"<nil>"}, "bptr": {"true"}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: &baz{
|
||||||
|
Ptr: intp(5),
|
||||||
|
},
|
||||||
|
expected: url.Values{"ptr": {"5"}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user