mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Add conversion to properly parse query parameter propagationPolicy
This commit is contained in:
parent
88c25ca2d9
commit
294e00c669
@ -75,6 +75,8 @@ func AddConversionFuncs(scheme *runtime.Scheme) error {
|
|||||||
Convert_unversioned_LabelSelector_to_map,
|
Convert_unversioned_LabelSelector_to_map,
|
||||||
|
|
||||||
Convert_Slice_string_To_Slice_int32,
|
Convert_Slice_string_To_Slice_int32,
|
||||||
|
|
||||||
|
Convert_Slice_string_To_v1_DeletionPropagation,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,3 +306,13 @@ func Convert_Slice_string_To_Slice_int32(in *[]string, out *[]int32, s conversio
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert_Slice_string_To_v1_DeletionPropagation allows converting a URL query parameter propagationPolicy
|
||||||
|
func Convert_Slice_string_To_v1_DeletionPropagation(input *[]string, out *DeletionPropagation, s conversion.Scope) error {
|
||||||
|
if len(*input) > 0 {
|
||||||
|
*out = DeletionPropagation((*input)[0])
|
||||||
|
} else {
|
||||||
|
*out = ""
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -47,3 +47,38 @@ func TestMapToLabelSelectorRoundTrip(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConvertSliceStringToDeletionPropagation(t *testing.T) {
|
||||||
|
tcs := []struct {
|
||||||
|
Input []string
|
||||||
|
Output v1.DeletionPropagation
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
Input: nil,
|
||||||
|
Output: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: []string{},
|
||||||
|
Output: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: []string{"foo"},
|
||||||
|
Output: "foo",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: []string{"bar", "foo"},
|
||||||
|
Output: "bar",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tcs {
|
||||||
|
var dp v1.DeletionPropagation
|
||||||
|
if err := v1.Convert_Slice_string_To_v1_DeletionPropagation(&tc.Input, &dp, nil); err != nil {
|
||||||
|
t.Errorf("Convert_Slice_string_To_v1_DeletionPropagation(%#v): %v", tc.Input, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !apiequality.Semantic.DeepEqual(dp, tc.Output) {
|
||||||
|
t.Errorf("slice string to DeletionPropagation conversion failed: got %v; want %v", dp, tc.Output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user