Rename IPFamilyPolicyType => IPFamilyPolicy

This commit is contained in:
Tim Hockin 2021-11-09 23:09:35 -08:00
parent 65361245ed
commit 55232e2ef7
13 changed files with 933 additions and 928 deletions

View File

@ -157,7 +157,7 @@ func SetIPFamilies(families ...api.IPFamily) Tweak {
} }
// SetIPFamilyPolicy sets the service IPFamilyPolicy field. // SetIPFamilyPolicy sets the service IPFamilyPolicy field.
func SetIPFamilyPolicy(policy api.IPFamilyPolicyType) Tweak { func SetIPFamilyPolicy(policy api.IPFamilyPolicy) Tweak {
return func(svc *api.Service) { return func(svc *api.Service) {
svc.Spec.IPFamilyPolicy = &policy svc.Spec.IPFamilyPolicy = &policy
} }

View File

@ -3736,27 +3736,27 @@ const (
IPv6Protocol IPFamily = "IPv6" IPv6Protocol IPFamily = "IPv6"
) )
// IPFamilyPolicyType represents the dual-stack-ness requested or required by a Service // IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
type IPFamilyPolicyType string type IPFamilyPolicy string
const ( const (
// IPFamilyPolicySingleStack indicates that this service is required to have a single IPFamily. // IPFamilyPolicySingleStack indicates that this service is required to have a single IPFamily.
// The IPFamily assigned is based on the default IPFamily used by the cluster // The IPFamily assigned is based on the default IPFamily used by the cluster
// or as identified by service.spec.ipFamilies field // or as identified by service.spec.ipFamilies field
IPFamilyPolicySingleStack IPFamilyPolicyType = "SingleStack" IPFamilyPolicySingleStack IPFamilyPolicy = "SingleStack"
// IPFamilyPolicyPreferDualStack indicates that this service prefers dual-stack when // IPFamilyPolicyPreferDualStack indicates that this service prefers dual-stack when
// the cluster is configured for dual-stack. If the cluster is not configured // the cluster is configured for dual-stack. If the cluster is not configured
// for dual-stack the service will be assigned a single IPFamily. If the IPFamily is not // for dual-stack the service will be assigned a single IPFamily. If the IPFamily is not
// set in service.spec.ipFamilies then the service will be assigned the default IPFamily // set in service.spec.ipFamilies then the service will be assigned the default IPFamily
// configured on the cluster // configured on the cluster
IPFamilyPolicyPreferDualStack IPFamilyPolicyType = "PreferDualStack" IPFamilyPolicyPreferDualStack IPFamilyPolicy = "PreferDualStack"
// IPFamilyPolicyRequireDualStack indicates that this service requires dual-stack. Using // IPFamilyPolicyRequireDualStack indicates that this service requires dual-stack. Using
// IPFamilyPolicyRequireDualStack on a single stack cluster will result in validation errors. The // IPFamilyPolicyRequireDualStack on a single stack cluster will result in validation errors. The
// IPFamilies (and their order) assigned to this service is based on service.spec.ipFamilies. If // IPFamilies (and their order) assigned to this service is based on service.spec.ipFamilies. If
// service.spec.ipFamilies was not provided then it will be assigned according to how they are // service.spec.ipFamilies was not provided then it will be assigned according to how they are
// configured on the cluster. If service.spec.ipFamilies has only one entry then the alternative // configured on the cluster. If service.spec.ipFamilies has only one entry then the alternative
// IPFamily will be added by apiserver // IPFamily will be added by apiserver
IPFamilyPolicyRequireDualStack IPFamilyPolicyType = "RequireDualStack" IPFamilyPolicyRequireDualStack IPFamilyPolicy = "RequireDualStack"
) )
// ServiceSpec describes the attributes that a user creates on a service // ServiceSpec describes the attributes that a user creates on a service
@ -3829,7 +3829,7 @@ type ServiceSpec struct {
// to this service can be controlled by service.spec.ipFamilies and service.spec.clusterIPs // to this service can be controlled by service.spec.ipFamilies and service.spec.clusterIPs
// respectively. // respectively.
// +optional // +optional
IPFamilyPolicy *IPFamilyPolicyType IPFamilyPolicy *IPFamilyPolicy
// ExternalName is the external reference that kubedns or equivalent will // ExternalName is the external reference that kubedns or equivalent will
// return as a CNAME record for this service. No proxying will be involved. // return as a CNAME record for this service. No proxying will be involved.

View File

@ -7709,7 +7709,7 @@ func autoConvert_v1_ServiceSpec_To_core_ServiceSpec(in *v1.ServiceSpec, out *cor
out.PublishNotReadyAddresses = in.PublishNotReadyAddresses out.PublishNotReadyAddresses = in.PublishNotReadyAddresses
out.SessionAffinityConfig = (*core.SessionAffinityConfig)(unsafe.Pointer(in.SessionAffinityConfig)) out.SessionAffinityConfig = (*core.SessionAffinityConfig)(unsafe.Pointer(in.SessionAffinityConfig))
out.IPFamilies = *(*[]core.IPFamily)(unsafe.Pointer(&in.IPFamilies)) out.IPFamilies = *(*[]core.IPFamily)(unsafe.Pointer(&in.IPFamilies))
out.IPFamilyPolicy = (*core.IPFamilyPolicyType)(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.ServiceInternalTrafficPolicyType)(unsafe.Pointer(in.InternalTrafficPolicy))
@ -7728,7 +7728,7 @@ func autoConvert_core_ServiceSpec_To_v1_ServiceSpec(in *core.ServiceSpec, out *v
out.ClusterIP = in.ClusterIP out.ClusterIP = in.ClusterIP
out.ClusterIPs = *(*[]string)(unsafe.Pointer(&in.ClusterIPs)) out.ClusterIPs = *(*[]string)(unsafe.Pointer(&in.ClusterIPs))
out.IPFamilies = *(*[]v1.IPFamily)(unsafe.Pointer(&in.IPFamilies)) out.IPFamilies = *(*[]v1.IPFamily)(unsafe.Pointer(&in.IPFamilies))
out.IPFamilyPolicy = (*v1.IPFamilyPolicyType)(unsafe.Pointer(in.IPFamilyPolicy)) out.IPFamilyPolicy = (*v1.IPFamilyPolicy)(unsafe.Pointer(in.IPFamilyPolicy))
out.ExternalName = in.ExternalName out.ExternalName = in.ExternalName
out.ExternalIPs = *(*[]string)(unsafe.Pointer(&in.ExternalIPs)) out.ExternalIPs = *(*[]string)(unsafe.Pointer(&in.ExternalIPs))
out.LoadBalancerIP = in.LoadBalancerIP out.LoadBalancerIP = in.LoadBalancerIP

View File

@ -5375,7 +5375,7 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) {
} }
if in.IPFamilyPolicy != nil { if in.IPFamilyPolicy != nil {
in, out := &in.IPFamilyPolicy, &out.IPFamilyPolicy in, out := &in.IPFamilyPolicy, &out.IPFamilyPolicy
*out = new(IPFamilyPolicyType) *out = new(IPFamilyPolicy)
**out = **in **out = **in
} }
if in.ExternalIPs != nil { if in.ExternalIPs != nil {

View File

@ -1012,7 +1012,7 @@ func isMatchingPreferDualStackClusterIPFields(after After, before Before) bool {
// Helper to avoid nil-checks all over. Callers of this need to be checking // Helper to avoid nil-checks all over. Callers of this need to be checking
// for an exact value. // for an exact value.
func getIPFamilyPolicy(svc *api.Service) api.IPFamilyPolicyType { func getIPFamilyPolicy(svc *api.Service) api.IPFamilyPolicy {
if svc.Spec.IPFamilyPolicy == nil { if svc.Spec.IPFamilyPolicy == nil {
return "" // callers need to handle this return "" // callers need to handle this
} }

View File

@ -1239,7 +1239,7 @@ func proveHealthCheckNodePortDeallocated(t *testing.T, storage *wrapperRESTForTe
// functional tests of the registry // functional tests of the registry
// //
func fmtIPFamilyPolicy(pol *api.IPFamilyPolicyType) string { func fmtIPFamilyPolicy(pol *api.IPFamilyPolicy) string {
if pol == nil { if pol == nil {
return "<nil>" return "<nil>"
} }
@ -1453,7 +1453,7 @@ func TestCreateInitIPFields(t *testing.T) {
line string line string
svc *api.Service svc *api.Service
expectError bool expectError bool
expectPolicy api.IPFamilyPolicyType expectPolicy api.IPFamilyPolicy
expectFamilies []api.IPFamily expectFamilies []api.IPFamily
expectHeadless bool expectHeadless bool
} }
@ -5922,7 +5922,7 @@ func TestCreateInvalidClusterIPInputs(t *testing.T) {
name: "bad_ipFamilyPolicy", name: "bad_ipFamilyPolicy",
families: []api.IPFamily{api.IPv4Protocol}, families: []api.IPFamily{api.IPv4Protocol},
svc: svctest.MakeService("foo", svc: svctest.MakeService("foo",
svctest.SetIPFamilyPolicy(api.IPFamilyPolicyType("garbage"))), svctest.SetIPFamilyPolicy(api.IPFamilyPolicy("garbage"))),
expect: []string{"Unsupported value"}, expect: []string{"Unsupported value"},
}, { }, {
name: "requiredual_ipFamilyPolicy_on_singlestack", name: "requiredual_ipFamilyPolicy_on_singlestack",

File diff suppressed because it is too large Load Diff

View File

@ -4300,30 +4300,34 @@ const (
IPv6Protocol IPFamily = "IPv6" IPv6Protocol IPFamily = "IPv6"
) )
// IPFamilyPolicyType represents the dual-stack-ness requested or required by a Service // IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
// +enum // +enum
type IPFamilyPolicyType string type IPFamilyPolicy string
const ( const (
// IPFamilyPolicySingleStack indicates that this service is required to have a single IPFamily. // IPFamilyPolicySingleStack indicates that this service is required to have a single IPFamily.
// The IPFamily assigned is based on the default IPFamily used by the cluster // The IPFamily assigned is based on the default IPFamily used by the cluster
// or as identified by service.spec.ipFamilies field // or as identified by service.spec.ipFamilies field
IPFamilyPolicySingleStack IPFamilyPolicyType = "SingleStack" IPFamilyPolicySingleStack IPFamilyPolicy = "SingleStack"
// IPFamilyPolicyPreferDualStack indicates that this service prefers dual-stack when // IPFamilyPolicyPreferDualStack indicates that this service prefers dual-stack when
// the cluster is configured for dual-stack. If the cluster is not configured // the cluster is configured for dual-stack. If the cluster is not configured
// for dual-stack the service will be assigned a single IPFamily. If the IPFamily is not // for dual-stack the service will be assigned a single IPFamily. If the IPFamily is not
// set in service.spec.ipFamilies then the service will be assigned the default IPFamily // set in service.spec.ipFamilies then the service will be assigned the default IPFamily
// configured on the cluster // configured on the cluster
IPFamilyPolicyPreferDualStack IPFamilyPolicyType = "PreferDualStack" IPFamilyPolicyPreferDualStack IPFamilyPolicy = "PreferDualStack"
// IPFamilyPolicyRequireDualStack indicates that this service requires dual-stack. Using // IPFamilyPolicyRequireDualStack indicates that this service requires dual-stack. Using
// IPFamilyPolicyRequireDualStack on a single stack cluster will result in validation errors. The // IPFamilyPolicyRequireDualStack on a single stack cluster will result in validation errors. The
// IPFamilies (and their order) assigned to this service is based on service.spec.ipFamilies. If // IPFamilies (and their order) assigned to this service is based on service.spec.ipFamilies. If
// service.spec.ipFamilies was not provided then it will be assigned according to how they are // service.spec.ipFamilies was not provided then it will be assigned according to how they are
// configured on the cluster. If service.spec.ipFamilies has only one entry then the alternative // configured on the cluster. If service.spec.ipFamilies has only one entry then the alternative
// IPFamily will be added by apiserver // IPFamily will be added by apiserver
IPFamilyPolicyRequireDualStack IPFamilyPolicyType = "RequireDualStack" IPFamilyPolicyRequireDualStack IPFamilyPolicy = "RequireDualStack"
) )
// for backwards compat
// +enum
type IPFamilyPolicyType = IPFamilyPolicy
// ServiceSpec describes the attributes that a user creates on a service. // ServiceSpec describes the attributes that a user creates on a service.
type ServiceSpec struct { type ServiceSpec struct {
// The list of ports that are exposed by this service. // The list of ports that are exposed by this service.
@ -4528,7 +4532,7 @@ type ServiceSpec struct {
// ipFamilies and clusterIPs fields depend on the value of this field. This // ipFamilies and clusterIPs fields depend on the value of this field. This
// field will be wiped when updating a service to type ExternalName. // field will be wiped when updating a service to type ExternalName.
// +optional // +optional
IPFamilyPolicy *IPFamilyPolicyType `json:"ipFamilyPolicy,omitempty" protobuf:"bytes,17,opt,name=ipFamilyPolicy,casttype=IPFamilyPolicyType"` IPFamilyPolicy *IPFamilyPolicy `json:"ipFamilyPolicy,omitempty" protobuf:"bytes,17,opt,name=ipFamilyPolicy,casttype=IPFamilyPolicy"`
// allocateLoadBalancerNodePorts defines if NodePorts will be automatically // allocateLoadBalancerNodePorts defines if NodePorts will be automatically
// allocated for services with type LoadBalancer. Default is "true". It // allocated for services with type LoadBalancer. Default is "true". It

View File

@ -5405,7 +5405,7 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) {
} }
if in.IPFamilyPolicy != nil { if in.IPFamilyPolicy != nil {
in, out := &in.IPFamilyPolicy, &out.IPFamilyPolicy in, out := &in.IPFamilyPolicy, &out.IPFamilyPolicy
*out = new(IPFamilyPolicyType) *out = new(IPFamilyPolicy)
**out = **in **out = **in
} }
if in.AllocateLoadBalancerNodePorts != nil { if in.AllocateLoadBalancerNodePorts != nil {

View File

@ -40,7 +40,7 @@ type ServiceSpecApplyConfiguration struct {
PublishNotReadyAddresses *bool `json:"publishNotReadyAddresses,omitempty"` PublishNotReadyAddresses *bool `json:"publishNotReadyAddresses,omitempty"`
SessionAffinityConfig *SessionAffinityConfigApplyConfiguration `json:"sessionAffinityConfig,omitempty"` SessionAffinityConfig *SessionAffinityConfigApplyConfiguration `json:"sessionAffinityConfig,omitempty"`
IPFamilies []corev1.IPFamily `json:"ipFamilies,omitempty"` IPFamilies []corev1.IPFamily `json:"ipFamilies,omitempty"`
IPFamilyPolicy *corev1.IPFamilyPolicyType `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.ServiceInternalTrafficPolicyType `json:"internalTrafficPolicy,omitempty"`
@ -194,7 +194,7 @@ func (b *ServiceSpecApplyConfiguration) WithIPFamilies(values ...corev1.IPFamily
// WithIPFamilyPolicy sets the IPFamilyPolicy field in the declarative configuration to the given value // WithIPFamilyPolicy sets the IPFamilyPolicy 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 IPFamilyPolicy field is set to the value of the last call. // If called multiple times, the IPFamilyPolicy field is set to the value of the last call.
func (b *ServiceSpecApplyConfiguration) WithIPFamilyPolicy(value corev1.IPFamilyPolicyType) *ServiceSpecApplyConfiguration { func (b *ServiceSpecApplyConfiguration) WithIPFamilyPolicy(value corev1.IPFamilyPolicy) *ServiceSpecApplyConfiguration {
b.IPFamilyPolicy = &value b.IPFamilyPolicy = &value
return b return b
} }

View File

@ -694,7 +694,7 @@ func validateNumOfServicePorts(svc *v1.Service, expectedNumOfPorts int) {
} }
} }
func validateServiceAndClusterIPFamily(svc *v1.Service, expectedIPFamilies []v1.IPFamily, expectedPolicy *v1.IPFamilyPolicyType) { func validateServiceAndClusterIPFamily(svc *v1.Service, expectedIPFamilies []v1.IPFamily, expectedPolicy *v1.IPFamilyPolicy) {
if len(svc.Spec.IPFamilies) != len(expectedIPFamilies) { if len(svc.Spec.IPFamilies) != len(expectedIPFamilies) {
framework.Failf("service ip family nil for service %s/%s", svc.Namespace, svc.Name) framework.Failf("service ip family nil for service %s/%s", svc.Namespace, svc.Name)
} }
@ -777,7 +777,7 @@ func checkNetworkConnectivity(ip, port string, timeout int) []string {
} }
// createService returns a service spec with defined arguments // createService returns a service spec with defined arguments
func createService(name, ns string, labels map[string]string, ipFamilyPolicy *v1.IPFamilyPolicyType, ipFamilies []v1.IPFamily) *v1.Service { func createService(name, ns string, labels map[string]string, ipFamilyPolicy *v1.IPFamilyPolicy, ipFamilies []v1.IPFamily) *v1.Service {
return &v1.Service{ return &v1.Service{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,

View File

@ -115,7 +115,7 @@ func TestDualStackEndpoints(t *testing.T) {
name string name string
serviceType v1.ServiceType serviceType v1.ServiceType
ipFamilies []v1.IPFamily ipFamilies []v1.IPFamily
ipFamilyPolicy v1.IPFamilyPolicyType ipFamilyPolicy v1.IPFamilyPolicy
}{ }{
{ {
name: "Service IPv4 Only", name: "Service IPv4 Only",

View File

@ -68,7 +68,7 @@ func TestCreateServiceSingleStackIPv4(t *testing.T) {
serviceType v1.ServiceType serviceType v1.ServiceType
clusterIPs []string clusterIPs []string
ipFamilies []v1.IPFamily ipFamilies []v1.IPFamily
ipFamilyPolicy v1.IPFamilyPolicyType ipFamilyPolicy v1.IPFamilyPolicy
expectedIPFamilies []v1.IPFamily expectedIPFamilies []v1.IPFamily
expectError bool expectError bool
}{ }{
@ -282,7 +282,7 @@ func TestCreateServiceDualStackIPv6(t *testing.T) {
clusterIPs []string clusterIPs []string
ipFamilies []v1.IPFamily ipFamilies []v1.IPFamily
expectedIPFamilies []v1.IPFamily expectedIPFamilies []v1.IPFamily
ipFamilyPolicy v1.IPFamilyPolicyType ipFamilyPolicy v1.IPFamilyPolicy
expectError bool expectError bool
}{ }{
{ {
@ -497,7 +497,7 @@ func TestCreateServiceDualStackIPv4IPv6(t *testing.T) {
clusterIPs []string clusterIPs []string
ipFamilies []v1.IPFamily ipFamilies []v1.IPFamily
expectedIPFamilies []v1.IPFamily expectedIPFamilies []v1.IPFamily
ipFamilyPolicy v1.IPFamilyPolicyType ipFamilyPolicy v1.IPFamilyPolicy
expectError bool expectError bool
}{ }{
{ {
@ -725,7 +725,7 @@ func TestCreateServiceDualStackIPv6IPv4(t *testing.T) {
clusterIPs []string clusterIPs []string
ipFamilies []v1.IPFamily ipFamilies []v1.IPFamily
expectedIPFamilies []v1.IPFamily expectedIPFamilies []v1.IPFamily
ipFamilyPolicy v1.IPFamilyPolicyType ipFamilyPolicy v1.IPFamilyPolicy
expectError bool expectError bool
}{ }{
{ {