mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #84670 from wojtek-t/remove_conversion_funcs_3
Autogenerate missing conversions for corev1 options types
This commit is contained in:
commit
a9fb448723
209
pkg/apis/core/v1/zz_generated.conversion.go
generated
209
pkg/apis/core/v1/zz_generated.conversion.go
generated
@ -2011,6 +2011,26 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*v1.PodAttachOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v1_PodAttachOptions(a.(*url.Values), b.(*v1.PodAttachOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*v1.PodExecOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v1_PodExecOptions(a.(*url.Values), b.(*v1.PodExecOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*v1.PodLogOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v1_PodLogOptions(a.(*url.Values), b.(*v1.PodLogOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*v1.PodPortForwardOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v1_PodPortForwardOptions(a.(*url.Values), b.(*v1.PodPortForwardOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*v1.PodProxyOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v1_PodProxyOptions(a.(*url.Values), b.(*v1.PodProxyOptions), scope)
|
||||
}); err != nil {
|
||||
@ -5447,6 +5467,52 @@ func Convert_core_PodAttachOptions_To_v1_PodAttachOptions(in *core.PodAttachOpti
|
||||
return autoConvert_core_PodAttachOptions_To_v1_PodAttachOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v1_PodAttachOptions(in *url.Values, out *v1.PodAttachOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["stdin"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Stdin, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Stdin = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["stdout"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Stdout, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Stdout = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["stderr"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Stderr, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Stderr = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["tty"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.TTY, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.TTY = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["container"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Container, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Container = ""
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v1_PodAttachOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v1_PodAttachOptions(in *url.Values, out *v1.PodAttachOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v1_PodAttachOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_PodCondition_To_core_PodCondition(in *v1.PodCondition, out *core.PodCondition, s conversion.Scope) error {
|
||||
out.Type = core.PodConditionType(in.Type)
|
||||
out.Status = core.ConditionStatus(in.Status)
|
||||
@ -5553,6 +5619,57 @@ func Convert_core_PodExecOptions_To_v1_PodExecOptions(in *core.PodExecOptions, o
|
||||
return autoConvert_core_PodExecOptions_To_v1_PodExecOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v1_PodExecOptions(in *url.Values, out *v1.PodExecOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["stdin"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Stdin, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Stdin = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["stdout"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Stdout, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Stdout = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["stderr"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Stderr, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Stderr = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["tty"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.TTY, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.TTY = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["container"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Container, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Container = ""
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["command"]; ok && len(values) > 0 {
|
||||
out.Command = *(*[]string)(unsafe.Pointer(&values))
|
||||
} else {
|
||||
out.Command = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v1_PodExecOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v1_PodExecOptions(in *url.Values, out *v1.PodExecOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v1_PodExecOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_PodIP_To_core_PodIP(in *v1.PodIP, out *core.PodIP, s conversion.Scope) error {
|
||||
out.IP = in.IP
|
||||
return nil
|
||||
@ -5651,6 +5768,80 @@ func Convert_core_PodLogOptions_To_v1_PodLogOptions(in *core.PodLogOptions, out
|
||||
return autoConvert_core_PodLogOptions_To_v1_PodLogOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v1_PodLogOptions(in *url.Values, out *v1.PodLogOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["container"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Container, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Container = ""
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["follow"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Follow, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Follow = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["previous"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Previous, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Previous = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["sinceSeconds"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_Pointer_int64(&values, &out.SinceSeconds, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.SinceSeconds = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["sinceTime"]; ok && len(values) > 0 {
|
||||
if err := metav1.Convert_Slice_string_To_Pointer_v1_Time(&values, &out.SinceTime, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.SinceTime = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["timestamps"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.Timestamps, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Timestamps = false
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["tailLines"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_Pointer_int64(&values, &out.TailLines, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.TailLines = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["limitBytes"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_Pointer_int64(&values, &out.LimitBytes, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.LimitBytes = nil
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["insecureSkipTLSVerifyBackend"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_bool(&values, &out.InsecureSkipTLSVerifyBackend, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.InsecureSkipTLSVerifyBackend = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v1_PodLogOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v1_PodLogOptions(in *url.Values, out *v1.PodLogOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v1_PodLogOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_PodPortForwardOptions_To_core_PodPortForwardOptions(in *v1.PodPortForwardOptions, out *core.PodPortForwardOptions, s conversion.Scope) error {
|
||||
out.Ports = *(*[]int32)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
@ -5671,6 +5862,24 @@ func Convert_core_PodPortForwardOptions_To_v1_PodPortForwardOptions(in *core.Pod
|
||||
return autoConvert_core_PodPortForwardOptions_To_v1_PodPortForwardOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v1_PodPortForwardOptions(in *url.Values, out *v1.PodPortForwardOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["ports"]; ok && len(values) > 0 {
|
||||
if err := metav1.Convert_Slice_string_To_Slice_int32(&values, &out.Ports, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Ports = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v1_PodPortForwardOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v1_PodPortForwardOptions(in *url.Values, out *v1.PodPortForwardOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v1_PodPortForwardOptions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_PodProxyOptions_To_core_PodProxyOptions(in *v1.PodProxyOptions, out *core.PodProxyOptions, s conversion.Scope) error {
|
||||
out.Path = in.Path
|
||||
return nil
|
||||
|
@ -4774,6 +4774,7 @@ type Preconditions struct {
|
||||
UID *types.UID `json:"uid,omitempty" protobuf:"bytes,1,opt,name=uid,casttype=k8s.io/apimachinery/pkg/types.UID"`
|
||||
}
|
||||
|
||||
// +k8s:conversion-gen:explicit-from=net/url.Values
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PodLogOptions is the query options for a Pod's logs REST call.
|
||||
@ -4825,6 +4826,7 @@ type PodLogOptions struct {
|
||||
InsecureSkipTLSVerifyBackend bool `json:"insecureSkipTLSVerifyBackend,omitempty" protobuf:"varint,9,opt,name=insecureSkipTLSVerifyBackend"`
|
||||
}
|
||||
|
||||
// +k8s:conversion-gen:explicit-from=net/url.Values
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PodAttachOptions is the query options to a Pod's remote attach call.
|
||||
@ -4862,6 +4864,7 @@ type PodAttachOptions struct {
|
||||
Container string `json:"container,omitempty" protobuf:"bytes,5,opt,name=container"`
|
||||
}
|
||||
|
||||
// +k8s:conversion-gen:explicit-from=net/url.Values
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PodExecOptions is the query options to a Pod's remote exec call.
|
||||
@ -4900,6 +4903,7 @@ type PodExecOptions struct {
|
||||
Command []string `json:"command" protobuf:"bytes,6,rep,name=command"`
|
||||
}
|
||||
|
||||
// +k8s:conversion-gen:explicit-from=net/url.Values
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// PodPortForwardOptions is the query options to a Pod's port forward call
|
||||
|
@ -24,6 +24,7 @@ go_test(
|
||||
deps = [
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
|
@ -45,6 +45,7 @@ func AddConversionFuncs(scheme *runtime.Scheme) error {
|
||||
Convert_v1_Duration_To_Pointer_v1_Duration,
|
||||
|
||||
Convert_Slice_string_To_v1_Time,
|
||||
Convert_Slice_string_To_Pointer_v1_Time,
|
||||
|
||||
Convert_v1_Time_To_v1_Time,
|
||||
Convert_v1_MicroTime_To_v1_MicroTime,
|
||||
@ -263,6 +264,22 @@ func Convert_Slice_string_To_v1_Time(in *[]string, out *Time, s conversion.Scope
|
||||
return out.UnmarshalQueryParameter(str)
|
||||
}
|
||||
|
||||
func Convert_Slice_string_To_Pointer_v1_Time(in *[]string, out **Time, s conversion.Scope) error {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
str := ""
|
||||
if len(*in) > 0 {
|
||||
str = (*in)[0]
|
||||
}
|
||||
temp := Time{}
|
||||
if err := temp.UnmarshalQueryParameter(str); err != nil {
|
||||
return err
|
||||
}
|
||||
*out = &temp
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_string_To_labels_Selector(in *string, out *labels.Selector, s conversion.Scope) error {
|
||||
selector, err := labels.Parse(*in)
|
||||
if err != nil {
|
||||
|
@ -17,10 +17,13 @@ limitations under the License.
|
||||
package v1_test
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func TestMapToLabelSelectorRoundTrip(t *testing.T) {
|
||||
@ -82,3 +85,50 @@ func TestConvertSliceStringToDeletionPropagation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUrlValuesToPointerTime(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
v1.AddConversionFuncs(scheme)
|
||||
|
||||
type testType struct {
|
||||
Time *v1.Time `json:"time"`
|
||||
}
|
||||
|
||||
t1 := v1.Date(1998, time.May, 5, 5, 5, 5, 0, time.UTC)
|
||||
t1String := t1.Format(time.RFC3339)
|
||||
t2 := v1.Date(2000, time.June, 6, 6, 6, 6, 0, time.UTC)
|
||||
t2String := t2.Format(time.RFC3339)
|
||||
|
||||
tcs := []struct {
|
||||
Input url.Values
|
||||
Output *v1.Time
|
||||
}{
|
||||
{
|
||||
Input: url.Values{},
|
||||
Output: nil,
|
||||
},
|
||||
{
|
||||
Input: url.Values{"time": []string{}},
|
||||
Output: &v1.Time{},
|
||||
},
|
||||
{
|
||||
Input: url.Values{"time": []string{""}},
|
||||
Output: &v1.Time{},
|
||||
},
|
||||
{
|
||||
Input: url.Values{"time": []string{t1String, t2String}},
|
||||
Output: &t1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
result := &testType{}
|
||||
if err := scheme.Convert(&tc.Input, &result, nil); err != nil {
|
||||
t.Errorf("Failed to convert []string to *metav1.Time %#v: %v", tc.Input, err)
|
||||
continue
|
||||
}
|
||||
if !apiequality.Semantic.DeepEqual(result.Time, tc.Output) {
|
||||
t.Errorf("Unexpected output: %v, expected: %v", result.Time, tc.Output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,11 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*[]string)(nil), (**Time)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_Slice_string_To_Pointer_v1_Time(a.(*[]string), b.(**Time), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*[]string)(nil), (*[]int32)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_Slice_string_To_Slice_int32(a.(*[]string), b.(*[]int32), scope)
|
||||
}); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user