Merge pull request #99662 from swetharepakula/eps-ga-api-changes
Graduate EndpointSlice API to GA
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery/v1alpha1"
|
||||
v1 "k8s.io/kubernetes/pkg/apis/discovery/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery/v1beta1"
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ func init() {
|
||||
// Install registers the API group and adds types to a scheme
|
||||
func Install(scheme *runtime.Scheme) {
|
||||
utilruntime.Must(discovery.AddToScheme(scheme))
|
||||
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
||||
utilruntime.Must(v1beta1.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1alpha1.SchemeGroupVersion))
|
||||
utilruntime.Must(v1.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1.SchemeGroupVersion))
|
||||
}
|
||||
|
@@ -87,26 +87,19 @@ type Endpoint struct {
|
||||
// endpoint.
|
||||
// +optional
|
||||
TargetRef *api.ObjectReference
|
||||
// topology contains arbitrary topology information associated with the
|
||||
// endpoint. These key/value pairs must conform with the label format.
|
||||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
|
||||
// Topology may include a maximum of 16 key/value pairs. This includes, but
|
||||
// is not limited to the following well known keys:
|
||||
// * kubernetes.io/hostname: the value indicates the hostname of the node
|
||||
// where the endpoint is located. This should match the corresponding
|
||||
// node label.
|
||||
// * topology.kubernetes.io/zone: the value indicates the zone where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// * topology.kubernetes.io/region: the value indicates the region where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// This field is deprecated and will be removed in future api versions.
|
||||
// deprecatedTopology is deprecated and only retained for round-trip
|
||||
// compatibility with v1beta1 Topology field. When v1beta1 is removed, this
|
||||
// should be removed, too.
|
||||
// +optional
|
||||
Topology map[string]string
|
||||
DeprecatedTopology map[string]string
|
||||
// nodeName represents the name of the Node hosting this endpoint. This can
|
||||
// be used to determine endpoints local to a Node. This field can be enabled
|
||||
// with the EndpointSliceNodeName feature gate.
|
||||
// +optional
|
||||
NodeName *string
|
||||
// zone is the name of the Zone this endpoint exists in.
|
||||
// +optional
|
||||
Zone *string
|
||||
}
|
||||
|
||||
// EndpointConditions represents the current condition of an endpoint.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,11 +14,11 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
package v1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
discoveryv1 "k8s.io/api/discovery/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_EndpointPort(obj *discoveryv1alpha1.EndpointPort) {
|
||||
func SetDefaults_EndpointPort(obj *discoveryv1.EndpointPort) {
|
||||
if obj.Name == nil {
|
||||
obj.Name = &defaultPortName
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1_test
|
||||
package v1_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discovery "k8s.io/api/discovery/v1alpha1"
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
_ "k8s.io/kubernetes/pkg/apis/discovery/install"
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,8 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/discovery
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/discovery/v1alpha1
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/discovery/v1
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/discovery/v1alpha1
|
||||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/discovery/v1
|
||||
|
||||
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/discovery/v1alpha1"
|
||||
package v1 // import "k8s.io/kubernetes/pkg/apis/discovery/v1"
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
package v1
|
||||
|
||||
import (
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
discoveryv1 "k8s.io/api/discovery/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
const GroupName = "discovery.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
@@ -33,7 +33,7 @@ func Resource(resource string) schema.GroupResource {
|
||||
}
|
||||
|
||||
var (
|
||||
localSchemeBuilder = &discoveryv1alpha1.SchemeBuilder
|
||||
localSchemeBuilder = &discoveryv1.SchemeBuilder
|
||||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
)
|
||||
|
226
pkg/apis/discovery/v1/zz_generated.conversion.go
generated
Normal file
226
pkg/apis/discovery/v1/zz_generated.conversion.go
generated
Normal file
@@ -0,0 +1,226 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
unsafe "unsafe"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/discovery/v1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
discovery "k8s.io/kubernetes/pkg/apis/discovery"
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(RegisterConversions)
|
||||
}
|
||||
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*v1.Endpoint)(nil), (*discovery.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1_Endpoint_To_discovery_Endpoint(a.(*v1.Endpoint), b.(*discovery.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.Endpoint)(nil), (*v1.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_Endpoint_To_v1_Endpoint(a.(*discovery.Endpoint), b.(*v1.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1.EndpointConditions)(nil), (*discovery.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1_EndpointConditions_To_discovery_EndpointConditions(a.(*v1.EndpointConditions), b.(*discovery.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointConditions)(nil), (*v1.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointConditions_To_v1_EndpointConditions(a.(*discovery.EndpointConditions), b.(*v1.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1.EndpointPort)(nil), (*discovery.EndpointPort)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1_EndpointPort_To_discovery_EndpointPort(a.(*v1.EndpointPort), b.(*discovery.EndpointPort), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointPort)(nil), (*v1.EndpointPort)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointPort_To_v1_EndpointPort(a.(*discovery.EndpointPort), b.(*v1.EndpointPort), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1.EndpointSlice)(nil), (*discovery.EndpointSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1_EndpointSlice_To_discovery_EndpointSlice(a.(*v1.EndpointSlice), b.(*discovery.EndpointSlice), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointSlice)(nil), (*v1.EndpointSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointSlice_To_v1_EndpointSlice(a.(*discovery.EndpointSlice), b.(*v1.EndpointSlice), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1.EndpointSliceList)(nil), (*discovery.EndpointSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1_EndpointSliceList_To_discovery_EndpointSliceList(a.(*v1.EndpointSliceList), b.(*discovery.EndpointSliceList), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointSliceList)(nil), (*v1.EndpointSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointSliceList_To_v1_EndpointSliceList(a.(*discovery.EndpointSliceList), b.(*v1.EndpointSliceList), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v1_Endpoint_To_discovery_Endpoint(in *v1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_v1_EndpointConditions_To_discovery_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*core.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.DeprecatedTopology = *(*map[string]string)(unsafe.Pointer(&in.DeprecatedTopology))
|
||||
out.NodeName = (*string)(unsafe.Pointer(in.NodeName))
|
||||
out.Zone = (*string)(unsafe.Pointer(in.Zone))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_Endpoint_To_discovery_Endpoint is an autogenerated conversion function.
|
||||
func Convert_v1_Endpoint_To_discovery_Endpoint(in *v1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_v1_Endpoint_To_discovery_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_Endpoint_To_v1_Endpoint(in *discovery.Endpoint, out *v1.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_discovery_EndpointConditions_To_v1_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*corev1.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.DeprecatedTopology = *(*map[string]string)(unsafe.Pointer(&in.DeprecatedTopology))
|
||||
out.NodeName = (*string)(unsafe.Pointer(in.NodeName))
|
||||
out.Zone = (*string)(unsafe.Pointer(in.Zone))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_Endpoint_To_v1_Endpoint is an autogenerated conversion function.
|
||||
func Convert_discovery_Endpoint_To_v1_Endpoint(in *discovery.Endpoint, out *v1.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_discovery_Endpoint_To_v1_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_EndpointConditions_To_discovery_EndpointConditions(in *v1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
out.Serving = (*bool)(unsafe.Pointer(in.Serving))
|
||||
out.Terminating = (*bool)(unsafe.Pointer(in.Terminating))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_EndpointConditions_To_discovery_EndpointConditions is an autogenerated conversion function.
|
||||
func Convert_v1_EndpointConditions_To_discovery_EndpointConditions(in *v1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
return autoConvert_v1_EndpointConditions_To_discovery_EndpointConditions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointConditions_To_v1_EndpointConditions(in *discovery.EndpointConditions, out *v1.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
out.Serving = (*bool)(unsafe.Pointer(in.Serving))
|
||||
out.Terminating = (*bool)(unsafe.Pointer(in.Terminating))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointConditions_To_v1_EndpointConditions is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointConditions_To_v1_EndpointConditions(in *discovery.EndpointConditions, out *v1.EndpointConditions, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointConditions_To_v1_EndpointConditions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_EndpointPort_To_discovery_EndpointPort(in *v1.EndpointPort, out *discovery.EndpointPort, s conversion.Scope) error {
|
||||
out.Name = (*string)(unsafe.Pointer(in.Name))
|
||||
out.Protocol = (*core.Protocol)(unsafe.Pointer(in.Protocol))
|
||||
out.Port = (*int32)(unsafe.Pointer(in.Port))
|
||||
out.AppProtocol = (*string)(unsafe.Pointer(in.AppProtocol))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_EndpointPort_To_discovery_EndpointPort is an autogenerated conversion function.
|
||||
func Convert_v1_EndpointPort_To_discovery_EndpointPort(in *v1.EndpointPort, out *discovery.EndpointPort, s conversion.Scope) error {
|
||||
return autoConvert_v1_EndpointPort_To_discovery_EndpointPort(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointPort_To_v1_EndpointPort(in *discovery.EndpointPort, out *v1.EndpointPort, s conversion.Scope) error {
|
||||
out.Name = (*string)(unsafe.Pointer(in.Name))
|
||||
out.Protocol = (*corev1.Protocol)(unsafe.Pointer(in.Protocol))
|
||||
out.Port = (*int32)(unsafe.Pointer(in.Port))
|
||||
out.AppProtocol = (*string)(unsafe.Pointer(in.AppProtocol))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointPort_To_v1_EndpointPort is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointPort_To_v1_EndpointPort(in *discovery.EndpointPort, out *v1.EndpointPort, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointPort_To_v1_EndpointPort(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_EndpointSlice_To_discovery_EndpointSlice(in *v1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = discovery.AddressType(in.AddressType)
|
||||
out.Endpoints = *(*[]discovery.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
out.Ports = *(*[]discovery.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_EndpointSlice_To_discovery_EndpointSlice is an autogenerated conversion function.
|
||||
func Convert_v1_EndpointSlice_To_discovery_EndpointSlice(in *v1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
return autoConvert_v1_EndpointSlice_To_discovery_EndpointSlice(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointSlice_To_v1_EndpointSlice(in *discovery.EndpointSlice, out *v1.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = v1.AddressType(in.AddressType)
|
||||
out.Endpoints = *(*[]v1.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
out.Ports = *(*[]v1.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointSlice_To_v1_EndpointSlice is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointSlice_To_v1_EndpointSlice(in *discovery.EndpointSlice, out *v1.EndpointSlice, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointSlice_To_v1_EndpointSlice(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]discovery.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_EndpointSliceList_To_discovery_EndpointSliceList is an autogenerated conversion function.
|
||||
func Convert_v1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
return autoConvert_v1_EndpointSliceList_To_discovery_EndpointSliceList(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointSliceList_To_v1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v1.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointSliceList_To_v1_EndpointSliceList is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointSliceList_To_v1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1.EndpointSliceList, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointSliceList_To_v1_EndpointSliceList(in, out, s)
|
||||
}
|
@@ -18,10 +18,10 @@ limitations under the License.
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
package v1
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
v1 "k8s.io/api/discovery/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -29,19 +29,19 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha1.EndpointSlice{}, func(obj interface{}) { SetObjectDefaults_EndpointSlice(obj.(*v1alpha1.EndpointSlice)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha1.EndpointSliceList{}, func(obj interface{}) { SetObjectDefaults_EndpointSliceList(obj.(*v1alpha1.EndpointSliceList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.EndpointSlice{}, func(obj interface{}) { SetObjectDefaults_EndpointSlice(obj.(*v1.EndpointSlice)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.EndpointSliceList{}, func(obj interface{}) { SetObjectDefaults_EndpointSliceList(obj.(*v1.EndpointSliceList)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_EndpointSlice(in *v1alpha1.EndpointSlice) {
|
||||
func SetObjectDefaults_EndpointSlice(in *v1.EndpointSlice) {
|
||||
for i := range in.Ports {
|
||||
a := &in.Ports[i]
|
||||
SetDefaults_EndpointPort(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_EndpointSliceList(in *v1alpha1.EndpointSliceList) {
|
||||
func SetObjectDefaults_EndpointSliceList(in *v1.EndpointSliceList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_EndpointSlice(a)
|
224
pkg/apis/discovery/v1alpha1/zz_generated.conversion.go
generated
224
pkg/apis/discovery/v1alpha1/zz_generated.conversion.go
generated
@@ -1,224 +0,0 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
unsafe "unsafe"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
discovery "k8s.io/kubernetes/pkg/apis/discovery"
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(RegisterConversions)
|
||||
}
|
||||
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.Endpoint)(nil), (*discovery.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_Endpoint_To_discovery_Endpoint(a.(*v1alpha1.Endpoint), b.(*discovery.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.Endpoint)(nil), (*v1alpha1.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_Endpoint_To_v1alpha1_Endpoint(a.(*discovery.Endpoint), b.(*v1alpha1.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointConditions)(nil), (*discovery.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(a.(*v1alpha1.EndpointConditions), b.(*discovery.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointConditions)(nil), (*v1alpha1.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(a.(*discovery.EndpointConditions), b.(*v1alpha1.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointPort)(nil), (*discovery.EndpointPort)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointPort_To_discovery_EndpointPort(a.(*v1alpha1.EndpointPort), b.(*discovery.EndpointPort), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointPort)(nil), (*v1alpha1.EndpointPort)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointPort_To_v1alpha1_EndpointPort(a.(*discovery.EndpointPort), b.(*v1alpha1.EndpointPort), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointSlice)(nil), (*discovery.EndpointSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(a.(*v1alpha1.EndpointSlice), b.(*discovery.EndpointSlice), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointSlice)(nil), (*v1alpha1.EndpointSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(a.(*discovery.EndpointSlice), b.(*v1alpha1.EndpointSlice), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointSliceList)(nil), (*discovery.EndpointSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(a.(*v1alpha1.EndpointSliceList), b.(*discovery.EndpointSliceList), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointSliceList)(nil), (*v1alpha1.EndpointSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(a.(*discovery.EndpointSliceList), b.(*v1alpha1.EndpointSliceList), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_Endpoint_To_discovery_Endpoint(in *v1alpha1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*core.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.Topology = *(*map[string]string)(unsafe.Pointer(&in.Topology))
|
||||
out.NodeName = (*string)(unsafe.Pointer(in.NodeName))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_Endpoint_To_discovery_Endpoint is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_Endpoint_To_discovery_Endpoint(in *v1alpha1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_Endpoint_To_discovery_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_Endpoint_To_v1alpha1_Endpoint(in *discovery.Endpoint, out *v1alpha1.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*v1.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.Topology = *(*map[string]string)(unsafe.Pointer(&in.Topology))
|
||||
out.NodeName = (*string)(unsafe.Pointer(in.NodeName))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_Endpoint_To_v1alpha1_Endpoint is an autogenerated conversion function.
|
||||
func Convert_discovery_Endpoint_To_v1alpha1_Endpoint(in *discovery.Endpoint, out *v1alpha1.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_discovery_Endpoint_To_v1alpha1_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(in *v1alpha1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
out.Serving = (*bool)(unsafe.Pointer(in.Serving))
|
||||
out.Terminating = (*bool)(unsafe.Pointer(in.Terminating))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(in *v1alpha1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(in *discovery.EndpointConditions, out *v1alpha1.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
out.Serving = (*bool)(unsafe.Pointer(in.Serving))
|
||||
out.Terminating = (*bool)(unsafe.Pointer(in.Terminating))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(in *discovery.EndpointConditions, out *v1alpha1.EndpointConditions, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointPort_To_discovery_EndpointPort(in *v1alpha1.EndpointPort, out *discovery.EndpointPort, s conversion.Scope) error {
|
||||
out.Name = (*string)(unsafe.Pointer(in.Name))
|
||||
out.Protocol = (*core.Protocol)(unsafe.Pointer(in.Protocol))
|
||||
out.Port = (*int32)(unsafe.Pointer(in.Port))
|
||||
out.AppProtocol = (*string)(unsafe.Pointer(in.AppProtocol))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointPort_To_discovery_EndpointPort is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointPort_To_discovery_EndpointPort(in *v1alpha1.EndpointPort, out *discovery.EndpointPort, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointPort_To_discovery_EndpointPort(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointPort_To_v1alpha1_EndpointPort(in *discovery.EndpointPort, out *v1alpha1.EndpointPort, s conversion.Scope) error {
|
||||
out.Name = (*string)(unsafe.Pointer(in.Name))
|
||||
out.Protocol = (*v1.Protocol)(unsafe.Pointer(in.Protocol))
|
||||
out.Port = (*int32)(unsafe.Pointer(in.Port))
|
||||
out.AppProtocol = (*string)(unsafe.Pointer(in.AppProtocol))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointPort_To_v1alpha1_EndpointPort is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointPort_To_v1alpha1_EndpointPort(in *discovery.EndpointPort, out *v1alpha1.EndpointPort, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointPort_To_v1alpha1_EndpointPort(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(in *v1alpha1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = discovery.AddressType(in.AddressType)
|
||||
out.Endpoints = *(*[]discovery.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
out.Ports = *(*[]discovery.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(in *v1alpha1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(in *discovery.EndpointSlice, out *v1alpha1.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = v1alpha1.AddressType(in.AddressType)
|
||||
out.Endpoints = *(*[]v1alpha1.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
out.Ports = *(*[]v1alpha1.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(in *discovery.EndpointSlice, out *v1alpha1.EndpointSlice, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1alpha1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]discovery.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1alpha1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1alpha1.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v1alpha1.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1alpha1.EndpointSliceList, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(in, out, s)
|
||||
}
|
92
pkg/apis/discovery/v1beta1/conversion.go
Normal file
92
pkg/apis/discovery/v1beta1/conversion.go
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/discovery/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
)
|
||||
|
||||
func Convert_v1beta1_Endpoint_To_discovery_Endpoint(in *v1beta1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
if err := autoConvert_v1beta1_Endpoint_To_discovery_Endpoint(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.Topology != nil {
|
||||
// Copy Topology into Deprecated Topology
|
||||
out.DeprecatedTopology = make(map[string]string, len(in.Topology))
|
||||
for k, v := range in.Topology {
|
||||
out.DeprecatedTopology[k] = v
|
||||
}
|
||||
|
||||
// Move zone from the topology map into a field
|
||||
if zone, ok := in.Topology[corev1.LabelTopologyZone]; ok {
|
||||
out.Zone = &zone
|
||||
delete(out.DeprecatedTopology, corev1.LabelTopologyZone)
|
||||
}
|
||||
|
||||
// Remove hostname from the topology map ONLY IF it is the same value as
|
||||
// nodeName. This preserves the (rather odd) ability to have different
|
||||
// values for topology[hostname] and nodename in v1beta1, without showing
|
||||
// duplicate values in v1.
|
||||
if node, ok := in.Topology[corev1.LabelHostname]; ok {
|
||||
if out.NodeName != nil && node == *out.NodeName {
|
||||
delete(out.DeprecatedTopology, corev1.LabelHostname)
|
||||
}
|
||||
}
|
||||
|
||||
// If zone & hostname were the only field in the map or topology was empty
|
||||
// set DeprecatedTopology to nil
|
||||
if len(out.DeprecatedTopology) == 0 {
|
||||
out.DeprecatedTopology = nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_discovery_Endpoint_To_v1beta1_Endpoint(in *discovery.Endpoint, out *v1beta1.Endpoint, s conversion.Scope) error {
|
||||
if err := autoConvert_discovery_Endpoint_To_v1beta1_Endpoint(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If no deprecated topology, zone or node field, no conversion is necessary
|
||||
if in.DeprecatedTopology == nil && in.Zone == nil && in.NodeName == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Copy Deprecated Topology into Topology
|
||||
out.Topology = make(map[string]string, len(in.DeprecatedTopology))
|
||||
for k, v := range in.DeprecatedTopology {
|
||||
out.Topology[k] = v
|
||||
}
|
||||
|
||||
// Add zone field into the topology map
|
||||
if in.Zone != nil {
|
||||
out.Topology[corev1.LabelTopologyZone] = *in.Zone
|
||||
}
|
||||
|
||||
// Add hostname into the topology map ONLY IF it is not already present.
|
||||
// This preserves the (rather odd) ability to have different values for
|
||||
// topology[hostname] and nodename in v1beta1.
|
||||
if in.NodeName != nil && out.Topology[corev1.LabelHostname] == "" {
|
||||
out.Topology[corev1.LabelHostname] = *in.NodeName
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
145
pkg/apis/discovery/v1beta1/conversion_test.go
Normal file
145
pkg/apis/discovery/v1beta1/conversion_test.go
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/discovery/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestEndpointZoneConverstion(t *testing.T) {
|
||||
testcases := []struct {
|
||||
desc string
|
||||
external v1beta1.Endpoint
|
||||
internal discovery.Endpoint
|
||||
}{
|
||||
{
|
||||
desc: "no topology field",
|
||||
external: v1beta1.Endpoint{},
|
||||
internal: discovery.Endpoint{},
|
||||
},
|
||||
{
|
||||
desc: "non empty topology map, but no zone",
|
||||
external: v1beta1.Endpoint{
|
||||
Topology: map[string]string{
|
||||
"key1": "val1",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
DeprecatedTopology: map[string]string{
|
||||
"key1": "val1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "non empty topology map, with zone",
|
||||
external: v1beta1.Endpoint{
|
||||
Topology: map[string]string{
|
||||
"key1": "val1",
|
||||
corev1.LabelTopologyZone: "zone1",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
DeprecatedTopology: map[string]string{
|
||||
"key1": "val1",
|
||||
},
|
||||
Zone: utilpointer.StringPtr("zone1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "only zone in topology map",
|
||||
external: v1beta1.Endpoint{
|
||||
Topology: map[string]string{
|
||||
corev1.LabelTopologyZone: "zone1",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
Zone: utilpointer.StringPtr("zone1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "nodeName and topology[hostname] are populated with different values",
|
||||
external: v1beta1.Endpoint{
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Topology: map[string]string{
|
||||
corev1.LabelHostname: "node-2",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
DeprecatedTopology: map[string]string{
|
||||
corev1.LabelHostname: "node-2",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "nodeName and topology[hostname] are populated with same values",
|
||||
external: v1beta1.Endpoint{
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Topology: map[string]string{
|
||||
corev1.LabelHostname: "node-1",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "only topology[hostname] is populated",
|
||||
external: v1beta1.Endpoint{
|
||||
Topology: map[string]string{
|
||||
corev1.LabelHostname: "node-1",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
DeprecatedTopology: map[string]string{
|
||||
corev1.LabelHostname: "node-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "only nodeName is populated",
|
||||
external: v1beta1.Endpoint{
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Topology: map[string]string{
|
||||
corev1.LabelHostname: "node-1",
|
||||
},
|
||||
},
|
||||
internal: discovery.Endpoint{
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
convertedInternal := discovery.Endpoint{}
|
||||
require.NoError(t, Convert_v1beta1_Endpoint_To_discovery_Endpoint(&tc.external, &convertedInternal, nil))
|
||||
assert.Equal(t, tc.internal, convertedInternal, "v1beta1.Endpoint -> discovery.Endpoint")
|
||||
|
||||
convertedV1beta1 := v1beta1.Endpoint{}
|
||||
require.NoError(t, Convert_discovery_Endpoint_To_v1beta1_Endpoint(&tc.internal, &convertedV1beta1, nil))
|
||||
assert.Equal(t, tc.external, convertedV1beta1, "discovery.Endpoint -> v1beta1.Endpoint")
|
||||
})
|
||||
}
|
||||
}
|
@@ -38,16 +38,6 @@ func init() {
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*v1beta1.Endpoint)(nil), (*discovery.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta1_Endpoint_To_discovery_Endpoint(a.(*v1beta1.Endpoint), b.(*discovery.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.Endpoint)(nil), (*v1beta1.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_Endpoint_To_v1beta1_Endpoint(a.(*discovery.Endpoint), b.(*v1beta1.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1beta1.EndpointConditions)(nil), (*discovery.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta1_EndpointConditions_To_discovery_EndpointConditions(a.(*v1beta1.EndpointConditions), b.(*discovery.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
@@ -88,6 +78,16 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*discovery.Endpoint)(nil), (*v1beta1.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_Endpoint_To_v1beta1_Endpoint(a.(*discovery.Endpoint), b.(*v1beta1.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*v1beta1.Endpoint)(nil), (*discovery.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta1_Endpoint_To_discovery_Endpoint(a.(*v1beta1.Endpoint), b.(*discovery.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -98,16 +98,11 @@ func autoConvert_v1beta1_Endpoint_To_discovery_Endpoint(in *v1beta1.Endpoint, ou
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*core.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.Topology = *(*map[string]string)(unsafe.Pointer(&in.Topology))
|
||||
// WARNING: in.Topology requires manual conversion: does not exist in peer-type
|
||||
out.NodeName = (*string)(unsafe.Pointer(in.NodeName))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1beta1_Endpoint_To_discovery_Endpoint is an autogenerated conversion function.
|
||||
func Convert_v1beta1_Endpoint_To_discovery_Endpoint(in *v1beta1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_v1beta1_Endpoint_To_discovery_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_Endpoint_To_v1beta1_Endpoint(in *discovery.Endpoint, out *v1beta1.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_discovery_EndpointConditions_To_v1beta1_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
@@ -115,16 +110,12 @@ func autoConvert_discovery_Endpoint_To_v1beta1_Endpoint(in *discovery.Endpoint,
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*v1.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.Topology = *(*map[string]string)(unsafe.Pointer(&in.Topology))
|
||||
// WARNING: in.DeprecatedTopology requires manual conversion: does not exist in peer-type
|
||||
out.NodeName = (*string)(unsafe.Pointer(in.NodeName))
|
||||
// WARNING: in.Zone requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_Endpoint_To_v1beta1_Endpoint is an autogenerated conversion function.
|
||||
func Convert_discovery_Endpoint_To_v1beta1_Endpoint(in *discovery.Endpoint, out *v1beta1.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_discovery_Endpoint_To_v1beta1_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1beta1_EndpointConditions_To_discovery_EndpointConditions(in *v1beta1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
out.Serving = (*bool)(unsafe.Pointer(in.Serving))
|
||||
@@ -178,7 +169,17 @@ func Convert_discovery_EndpointPort_To_v1beta1_EndpointPort(in *discovery.Endpoi
|
||||
func autoConvert_v1beta1_EndpointSlice_To_discovery_EndpointSlice(in *v1beta1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = discovery.AddressType(in.AddressType)
|
||||
out.Endpoints = *(*[]discovery.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
if in.Endpoints != nil {
|
||||
in, out := &in.Endpoints, &out.Endpoints
|
||||
*out = make([]discovery.Endpoint, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v1beta1_Endpoint_To_discovery_Endpoint(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Endpoints = nil
|
||||
}
|
||||
out.Ports = *(*[]discovery.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
@@ -191,7 +192,17 @@ func Convert_v1beta1_EndpointSlice_To_discovery_EndpointSlice(in *v1beta1.Endpoi
|
||||
func autoConvert_discovery_EndpointSlice_To_v1beta1_EndpointSlice(in *discovery.EndpointSlice, out *v1beta1.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = v1beta1.AddressType(in.AddressType)
|
||||
out.Endpoints = *(*[]v1beta1.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
if in.Endpoints != nil {
|
||||
in, out := &in.Endpoints, &out.Endpoints
|
||||
*out = make([]v1beta1.Endpoint, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_discovery_Endpoint_To_v1beta1_Endpoint(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Endpoints = nil
|
||||
}
|
||||
out.Ports = *(*[]v1beta1.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
@@ -203,7 +214,17 @@ func Convert_discovery_EndpointSlice_To_v1beta1_EndpointSlice(in *discovery.Endp
|
||||
|
||||
func autoConvert_v1beta1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1beta1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]discovery.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]discovery.EndpointSlice, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v1beta1_EndpointSlice_To_discovery_EndpointSlice(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -214,7 +235,17 @@ func Convert_v1beta1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1beta
|
||||
|
||||
func autoConvert_discovery_EndpointSliceList_To_v1beta1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1beta1.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v1beta1.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]v1beta1.EndpointSlice, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_discovery_EndpointSlice_To_v1beta1_EndpointSlice(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,9 @@ limitations under the License.
|
||||
package validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
|
||||
metavalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
@@ -110,11 +113,14 @@ func validateEndpoints(endpoints []discovery.Endpoint, addrType discovery.Addres
|
||||
}
|
||||
}
|
||||
|
||||
topologyPath := idxPath.Child("topology")
|
||||
if len(endpoint.Topology) > maxTopologyLabels {
|
||||
allErrs = append(allErrs, field.TooMany(topologyPath, len(endpoint.Topology), maxTopologyLabels))
|
||||
topologyPath := idxPath.Child("deprecatedTopology")
|
||||
if len(endpoint.DeprecatedTopology) > maxTopologyLabels {
|
||||
allErrs = append(allErrs, field.TooMany(topologyPath, len(endpoint.DeprecatedTopology), maxTopologyLabels))
|
||||
}
|
||||
allErrs = append(allErrs, metavalidation.ValidateLabels(endpoint.DeprecatedTopology, topologyPath)...)
|
||||
if _, found := endpoint.DeprecatedTopology[corev1.LabelTopologyZone]; found {
|
||||
allErrs = append(allErrs, field.InternalError(topologyPath.Key(corev1.LabelTopologyZone), fmt.Errorf("reserved key was not removed in conversion")))
|
||||
}
|
||||
allErrs = append(allErrs, metavalidation.ValidateLabels(endpoint.Topology, topologyPath)...)
|
||||
|
||||
if endpoint.Hostname != nil {
|
||||
allErrs = append(allErrs, apivalidation.ValidateDNS1123Label(*endpoint.Hostname, idxPath.Child("hostname"))...)
|
||||
|
@@ -21,6 +21,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
@@ -197,8 +198,8 @@ func TestValidateEndpointSlice(t *testing.T) {
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateIPAddresses(1),
|
||||
Topology: generateTopology(maxTopologyLabels),
|
||||
Addresses: generateIPAddresses(1),
|
||||
DeprecatedTopology: generateTopology(maxTopologyLabels),
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -321,8 +322,8 @@ func TestValidateEndpointSlice(t *testing.T) {
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateIPAddresses(1),
|
||||
Topology: map[string]string{"--INVALID": "example"},
|
||||
Addresses: generateIPAddresses(1),
|
||||
DeprecatedTopology: map[string]string{"--INVALID": "example"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -336,8 +337,8 @@ func TestValidateEndpointSlice(t *testing.T) {
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateIPAddresses(1),
|
||||
Topology: generateTopology(maxTopologyLabels + 1),
|
||||
Addresses: generateIPAddresses(1),
|
||||
DeprecatedTopology: generateTopology(maxTopologyLabels + 1),
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -454,6 +455,21 @@ func TestValidateEndpointSlice(t *testing.T) {
|
||||
expectedErrors: 3,
|
||||
endpointSlice: &discovery.EndpointSlice{},
|
||||
},
|
||||
"zone-key-topology": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: discovery.AddressTypeIPv4,
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateIPAddresses(1),
|
||||
DeprecatedTopology: map[string]string{corev1.LabelTopologyZone: "zone1"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, testCase := range testCases {
|
||||
|
9
pkg/apis/discovery/zz_generated.deepcopy.go
generated
9
pkg/apis/discovery/zz_generated.deepcopy.go
generated
@@ -44,8 +44,8 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
|
||||
*out = new(core.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.Topology != nil {
|
||||
in, out := &in.Topology, &out.Topology
|
||||
if in.DeprecatedTopology != nil {
|
||||
in, out := &in.DeprecatedTopology, &out.DeprecatedTopology
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
@@ -56,6 +56,11 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.Zone != nil {
|
||||
in, out := &in.Zone, &out.Zone
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user