ServiceInternalTrafficPolicyType: s/Type//

Rename ServiceInternalTrafficPolicyType => ServiceInternalTrafficPolicy
This commit is contained in:
Tim Hockin 2021-11-09 23:30:23 -08:00
parent d0e2b06850
commit dd0a50336e
No known key found for this signature in database
16 changed files with 945 additions and 941 deletions

View File

@ -177,7 +177,7 @@ func SetNodePorts(values ...int) Tweak {
} }
// SetInternalTrafficPolicy sets the internalTrafficPolicy field for a Service. // SetInternalTrafficPolicy sets the internalTrafficPolicy field for a Service.
func SetInternalTrafficPolicy(policy api.ServiceInternalTrafficPolicyType) Tweak { func SetInternalTrafficPolicy(policy api.ServiceInternalTrafficPolicy) Tweak {
return func(svc *api.Service) { return func(svc *api.Service) {
svc.Spec.InternalTrafficPolicy = &policy svc.Spec.InternalTrafficPolicy = &policy
} }

View File

@ -297,8 +297,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
types := []core.ServiceExternalTrafficPolicy{core.ServiceExternalTrafficPolicyCluster, core.ServiceExternalTrafficPolicyLocal} types := []core.ServiceExternalTrafficPolicy{core.ServiceExternalTrafficPolicyCluster, core.ServiceExternalTrafficPolicyLocal}
*p = types[c.Rand.Intn(len(types))] *p = types[c.Rand.Intn(len(types))]
}, },
func(p *core.ServiceInternalTrafficPolicyType, c fuzz.Continue) { func(p *core.ServiceInternalTrafficPolicy, c fuzz.Continue) {
types := []core.ServiceInternalTrafficPolicyType{core.ServiceInternalTrafficPolicyCluster, core.ServiceInternalTrafficPolicyLocal} types := []core.ServiceInternalTrafficPolicy{core.ServiceInternalTrafficPolicyCluster, core.ServiceInternalTrafficPolicyLocal}
*p = types[c.Rand.Intn(len(types))] *p = types[c.Rand.Intn(len(types))]
}, },
func(ct *core.Container, c fuzz.Continue) { func(ct *core.Container, c fuzz.Continue) {

View File

@ -3781,18 +3781,18 @@ const (
ServiceTypeExternalName ServiceType = "ExternalName" ServiceTypeExternalName ServiceType = "ExternalName"
) )
// ServiceInternalTrafficPolicyType describes the endpoint-selection policy for // ServiceInternalTrafficPolicy describes the endpoint-selection policy for
// traffic sent to the ClusterIP. // traffic sent to the ClusterIP.
type ServiceInternalTrafficPolicyType string type ServiceInternalTrafficPolicy string
const ( const (
// ServiceInternalTrafficPolicyCluster routes traffic to all endpoints. // ServiceInternalTrafficPolicyCluster routes traffic to all endpoints.
ServiceInternalTrafficPolicyCluster ServiceInternalTrafficPolicyType = "Cluster" ServiceInternalTrafficPolicyCluster ServiceInternalTrafficPolicy = "Cluster"
// ServiceInternalTrafficPolicyLocal routes traffic only to endpoints on the same // ServiceInternalTrafficPolicyLocal routes traffic only to endpoints on the same
// node as the traffic was received on (dropping the traffic if there are no // node as the traffic was received on (dropping the traffic if there are no
// local endpoints). // local endpoints).
ServiceInternalTrafficPolicyLocal ServiceInternalTrafficPolicyType = "Local" ServiceInternalTrafficPolicyLocal ServiceInternalTrafficPolicy = "Local"
) )
// ServiceExternalTrafficPolicy describes the endpoint-selection policy for // ServiceExternalTrafficPolicy describes the endpoint-selection policy for
@ -4064,7 +4064,7 @@ type ServiceSpec struct {
// "Cluster", uses the standard behavior of routing to all endpoints evenly // "Cluster", uses the standard behavior of routing to all endpoints evenly
// (possibly modified by topology and other features). // (possibly modified by topology and other features).
// +optional // +optional
InternalTrafficPolicy *ServiceInternalTrafficPolicyType InternalTrafficPolicy *ServiceInternalTrafficPolicy
} }
// ServicePort represents the port on which the service is exposed // ServicePort represents the port on which the service is exposed

View File

@ -1859,7 +1859,7 @@ func TestSetDefaultServiceInternalTrafficPolicy(t *testing.T) {
local := v1.ServiceInternalTrafficPolicyLocal local := v1.ServiceInternalTrafficPolicyLocal
testCases := []struct { testCases := []struct {
name string name string
expectedInternalTrafficPolicy *v1.ServiceInternalTrafficPolicyType expectedInternalTrafficPolicy *v1.ServiceInternalTrafficPolicy
svc v1.Service svc v1.Service
}{ }{
{ {

View File

@ -7858,7 +7858,7 @@ func autoConvert_v1_ServiceSpec_To_core_ServiceSpec(in *v1.ServiceSpec, out *cor
out.IPFamilyPolicy = (*core.IPFamilyPolicy)(unsafe.Pointer(in.IPFamilyPolicy)) out.IPFamilyPolicy = (*core.IPFamilyPolicy)(unsafe.Pointer(in.IPFamilyPolicy))
out.AllocateLoadBalancerNodePorts = (*bool)(unsafe.Pointer(in.AllocateLoadBalancerNodePorts)) out.AllocateLoadBalancerNodePorts = (*bool)(unsafe.Pointer(in.AllocateLoadBalancerNodePorts))
out.LoadBalancerClass = (*string)(unsafe.Pointer(in.LoadBalancerClass)) out.LoadBalancerClass = (*string)(unsafe.Pointer(in.LoadBalancerClass))
out.InternalTrafficPolicy = (*core.ServiceInternalTrafficPolicyType)(unsafe.Pointer(in.InternalTrafficPolicy)) out.InternalTrafficPolicy = (*core.ServiceInternalTrafficPolicy)(unsafe.Pointer(in.InternalTrafficPolicy))
return nil return nil
} }
@ -7886,7 +7886,7 @@ func autoConvert_core_ServiceSpec_To_v1_ServiceSpec(in *core.ServiceSpec, out *v
out.PublishNotReadyAddresses = in.PublishNotReadyAddresses out.PublishNotReadyAddresses = in.PublishNotReadyAddresses
out.AllocateLoadBalancerNodePorts = (*bool)(unsafe.Pointer(in.AllocateLoadBalancerNodePorts)) out.AllocateLoadBalancerNodePorts = (*bool)(unsafe.Pointer(in.AllocateLoadBalancerNodePorts))
out.LoadBalancerClass = (*string)(unsafe.Pointer(in.LoadBalancerClass)) out.LoadBalancerClass = (*string)(unsafe.Pointer(in.LoadBalancerClass))
out.InternalTrafficPolicy = (*v1.ServiceInternalTrafficPolicyType)(unsafe.Pointer(in.InternalTrafficPolicy)) out.InternalTrafficPolicy = (*v1.ServiceInternalTrafficPolicy)(unsafe.Pointer(in.InternalTrafficPolicy))
return nil return nil
} }

View File

@ -13510,7 +13510,7 @@ func TestValidateServiceCreate(t *testing.T) {
{ {
name: "invalid internalTraffic field", name: "invalid internalTraffic field",
tweakSvc: func(s *core.Service) { tweakSvc: func(s *core.Service) {
invalid := core.ServiceInternalTrafficPolicyType("invalid") invalid := core.ServiceInternalTrafficPolicy("invalid")
s.Spec.InternalTrafficPolicy = &invalid s.Spec.InternalTrafficPolicy = &invalid
}, },
numErrs: 1, numErrs: 1,

View File

@ -5502,7 +5502,7 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) {
} }
if in.InternalTrafficPolicy != nil { if in.InternalTrafficPolicy != nil {
in, out := &in.InternalTrafficPolicy, &out.InternalTrafficPolicy in, out := &in.InternalTrafficPolicy, &out.InternalTrafficPolicy
*out = new(ServiceInternalTrafficPolicyType) *out = new(ServiceInternalTrafficPolicy)
**out = **in **out = **in
} }
return return

View File

@ -5620,7 +5620,7 @@ func TestInternalTrafficPolicyE2E(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
line int line int
internalTrafficPolicy *v1.ServiceInternalTrafficPolicyType internalTrafficPolicy *v1.ServiceInternalTrafficPolicy
featureGateOn bool featureGateOn bool
endpoints []endpoint endpoints []endpoint
expectEndpointRule bool expectEndpointRule bool
@ -8642,7 +8642,7 @@ func TestNoEndpointsMetric(t *testing.T) {
metrics.RegisterMetrics() metrics.RegisterMetrics()
testCases := []struct { testCases := []struct {
name string name string
internalTrafficPolicy *v1.ServiceInternalTrafficPolicyType internalTrafficPolicy *v1.ServiceInternalTrafficPolicy
externalTrafficPolicy v1.ServiceExternalTrafficPolicy externalTrafficPolicy v1.ServiceExternalTrafficPolicy
endpoints []endpoint endpoints []endpoint
expectedSyncProxyRulesNoLocalEndpointsTotalInternal int expectedSyncProxyRulesNoLocalEndpointsTotalInternal int

View File

@ -4805,7 +4805,7 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
internalTrafficPolicy *v1.ServiceInternalTrafficPolicyType internalTrafficPolicy *v1.ServiceInternalTrafficPolicy
endpoints []endpoint endpoints []endpoint
expectVirtualServer bool expectVirtualServer bool
expectLocalEntries bool expectLocalEntries bool
@ -5947,7 +5947,7 @@ func TestNoEndpointsMetric(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
internalTrafficPolicy *v1.ServiceInternalTrafficPolicyType internalTrafficPolicy *v1.ServiceInternalTrafficPolicy
externalTrafficPolicy v1.ServiceExternalTrafficPolicy externalTrafficPolicy v1.ServiceExternalTrafficPolicy
endpoints []endpoint endpoints []endpoint
expectedSyncProxyRulesNoLocalEndpointsTotalInternal int expectedSyncProxyRulesNoLocalEndpointsTotalInternal int

View File

@ -52,7 +52,7 @@ type BaseServicePortInfo struct {
healthCheckNodePort int healthCheckNodePort int
externalPolicyLocal bool externalPolicyLocal bool
internalPolicyLocal bool internalPolicyLocal bool
internalTrafficPolicy *v1.ServiceInternalTrafficPolicyType internalTrafficPolicy *v1.ServiceInternalTrafficPolicy
hintsAnnotation string hintsAnnotation string
} }
@ -128,7 +128,7 @@ func (bsvcPortInfo *BaseServicePortInfo) InternalPolicyLocal() bool {
} }
// InternalTrafficPolicy is part of ServicePort interface // InternalTrafficPolicy is part of ServicePort interface
func (bsvcPortInfo *BaseServicePortInfo) InternalTrafficPolicy() *v1.ServiceInternalTrafficPolicyType { func (bsvcPortInfo *BaseServicePortInfo) InternalTrafficPolicy() *v1.ServiceInternalTrafficPolicy {
return bsvcPortInfo.internalTrafficPolicy return bsvcPortInfo.internalTrafficPolicy
} }

View File

@ -88,7 +88,7 @@ type ServicePort interface {
// InternalPolicyLocal returns if a service has only node local endpoints for internal traffic. // InternalPolicyLocal returns if a service has only node local endpoints for internal traffic.
InternalPolicyLocal() bool InternalPolicyLocal() bool
// InternalTrafficPolicy returns service InternalTrafficPolicy // InternalTrafficPolicy returns service InternalTrafficPolicy
InternalTrafficPolicy() *v1.ServiceInternalTrafficPolicyType InternalTrafficPolicy() *v1.ServiceInternalTrafficPolicy
// HintsAnnotation returns the value of the v1.AnnotationTopologyAwareHints annotation. // HintsAnnotation returns the value of the v1.AnnotationTopologyAwareHints annotation.
HintsAnnotation() string HintsAnnotation() string
// ExternallyAccessible returns true if the service port is reachable via something // ExternallyAccessible returns true if the service port is reachable via something

View File

@ -1243,7 +1243,7 @@ func fmtIPFamilyPolicy(pol *api.IPFamilyPolicy) string {
return string(*pol) return string(*pol)
} }
func fmtInternalTrafficPolicy(pol *api.ServiceInternalTrafficPolicyType) string { func fmtInternalTrafficPolicy(pol *api.ServiceInternalTrafficPolicy) string {
if pol == nil { if pol == nil {
return "<nil>" return "<nil>"
} }
@ -11356,7 +11356,7 @@ func TestFeatureInternalTrafficPolicy(t *testing.T) {
prove := func(proofs ...svcTestProof) []svcTestProof { prove := func(proofs ...svcTestProof) []svcTestProof {
return proofs return proofs
} }
proveITP := func(want api.ServiceInternalTrafficPolicyType) svcTestProof { proveITP := func(want api.ServiceInternalTrafficPolicy) svcTestProof {
return func(t *testing.T, storage *wrapperRESTForTests, before, after *api.Service) { return func(t *testing.T, storage *wrapperRESTForTests, before, after *api.Service) {
t.Helper() t.Helper()
if got := after.Spec.InternalTrafficPolicy; got == nil { if got := after.Spec.InternalTrafficPolicy; got == nil {

File diff suppressed because it is too large Load Diff

View File

@ -4368,20 +4368,24 @@ const (
ServiceTypeExternalName ServiceType = "ExternalName" ServiceTypeExternalName ServiceType = "ExternalName"
) )
// ServiceInternalTrafficPolicyType describes how nodes distribute service traffic they // ServiceInternalTrafficPolicy describes how nodes distribute service traffic they
// receive on the ClusterIP. // receive on the ClusterIP.
// +enum // +enum
type ServiceInternalTrafficPolicyType string type ServiceInternalTrafficPolicy string
const ( const (
// ServiceInternalTrafficPolicyCluster routes traffic to all endpoints. // ServiceInternalTrafficPolicyCluster routes traffic to all endpoints.
ServiceInternalTrafficPolicyCluster ServiceInternalTrafficPolicyType = "Cluster" ServiceInternalTrafficPolicyCluster ServiceInternalTrafficPolicy = "Cluster"
// ServiceInternalTrafficPolicyLocal routes traffic only to endpoints on the same // ServiceInternalTrafficPolicyLocal routes traffic only to endpoints on the same
// node as the client pod (dropping the traffic if there are no local endpoints). // node as the client pod (dropping the traffic if there are no local endpoints).
ServiceInternalTrafficPolicyLocal ServiceInternalTrafficPolicyType = "Local" ServiceInternalTrafficPolicyLocal ServiceInternalTrafficPolicy = "Local"
) )
// for backwards compat
// +enum
type ServiceInternalTrafficPolicyType = ServiceInternalTrafficPolicy
// ServiceExternalTrafficPolicy describes how nodes distribute service traffic they // ServiceExternalTrafficPolicy describes how nodes distribute service traffic they
// receive on one of the Service's "externally-facing" addresses (NodePorts, ExternalIPs, // receive on one of the Service's "externally-facing" addresses (NodePorts, ExternalIPs,
// and LoadBalancer IPs. // and LoadBalancer IPs.
@ -4734,7 +4738,7 @@ type ServiceSpec struct {
// "Cluster", uses the standard behavior of routing to all endpoints evenly // "Cluster", uses the standard behavior of routing to all endpoints evenly
// (possibly modified by topology and other features). // (possibly modified by topology and other features).
// +optional // +optional
InternalTrafficPolicy *ServiceInternalTrafficPolicyType `json:"internalTrafficPolicy,omitempty" protobuf:"bytes,22,opt,name=internalTrafficPolicy"` InternalTrafficPolicy *ServiceInternalTrafficPolicy `json:"internalTrafficPolicy,omitempty" protobuf:"bytes,22,opt,name=internalTrafficPolicy"`
} }
// ServicePort contains information on service's port. // ServicePort contains information on service's port.

View File

@ -5517,7 +5517,7 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) {
} }
if in.InternalTrafficPolicy != nil { if in.InternalTrafficPolicy != nil {
in, out := &in.InternalTrafficPolicy, &out.InternalTrafficPolicy in, out := &in.InternalTrafficPolicy, &out.InternalTrafficPolicy
*out = new(ServiceInternalTrafficPolicyType) *out = new(ServiceInternalTrafficPolicy)
**out = **in **out = **in
} }
return return

View File

@ -43,7 +43,7 @@ type ServiceSpecApplyConfiguration struct {
IPFamilyPolicy *corev1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"` IPFamilyPolicy *corev1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
AllocateLoadBalancerNodePorts *bool `json:"allocateLoadBalancerNodePorts,omitempty"` AllocateLoadBalancerNodePorts *bool `json:"allocateLoadBalancerNodePorts,omitempty"`
LoadBalancerClass *string `json:"loadBalancerClass,omitempty"` LoadBalancerClass *string `json:"loadBalancerClass,omitempty"`
InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicyType `json:"internalTrafficPolicy,omitempty"` InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicy `json:"internalTrafficPolicy,omitempty"`
} }
// ServiceSpecApplyConfiguration constructs an declarative configuration of the ServiceSpec type for use with // ServiceSpecApplyConfiguration constructs an declarative configuration of the ServiceSpec type for use with
@ -218,7 +218,7 @@ func (b *ServiceSpecApplyConfiguration) WithLoadBalancerClass(value string) *Ser
// WithInternalTrafficPolicy sets the InternalTrafficPolicy field in the declarative configuration to the given value // WithInternalTrafficPolicy sets the InternalTrafficPolicy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the InternalTrafficPolicy field is set to the value of the last call. // If called multiple times, the InternalTrafficPolicy field is set to the value of the last call.
func (b *ServiceSpecApplyConfiguration) WithInternalTrafficPolicy(value corev1.ServiceInternalTrafficPolicyType) *ServiceSpecApplyConfiguration { func (b *ServiceSpecApplyConfiguration) WithInternalTrafficPolicy(value corev1.ServiceInternalTrafficPolicy) *ServiceSpecApplyConfiguration {
b.InternalTrafficPolicy = &value b.InternalTrafficPolicy = &value
return b return b
} }