Skip to content

Commit

Permalink
Fix ServiceSpec::cluster_i_ps to be emitted as cluster_ips
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnavion committed Aug 5, 2021
1 parent e908e4c commit 2e2e6c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions k8s-openapi-codegen-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ pub fn get_rust_ident(name: &str) -> std::borrow::Cow<'static, str> {
// Eg "JSONSchemas" => "json_schemas", but "externalIPs" => "external_ips" instead of "external_i_ps".
// Mostly happens with plurals of abbreviations.
match name {
"clusterIPs" => return "cluster_ips".into(),
"externalIPs" => return "external_ips".into(),
"nonResourceURLs" => return "non_resource_urls".into(),
"podCIDRs" => return "pod_cidrs".into(),
Expand Down
3 changes: 3 additions & 0 deletions k8s-openapi-tests/src/special_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ fn special_idents() {
let _ = api::FCVolumeSource { target_wwns: Default::default(), ..Default::default() };

let _ = api::ServiceSpec { external_ips: Default::default(), ..Default::default() };
k8s_openapi::k8s_if_ge_1_20! {
let _ = api::ServiceSpec { cluster_ips: Default::default(), ..Default::default() };
}

let _ = authorization::NonResourceRule { non_resource_urls: Default::default(), ..Default::default() };

Expand Down
16 changes: 8 additions & 8 deletions src/v1_20/api/core/v1/service_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct ServiceSpec {
/// ClusterIPs is a list of IP addresses assigned to this service, and are usually assigned randomly. If an address is specified manually, is in-range (as per system configuration), and is not in use, it will be allocated to the service; otherwise creation of the service will fail. This field may not be changed through updates unless the type field is also being changed to ExternalName (which requires this field to be empty) or the type field is being changed from ExternalName (in which case this field may optionally be specified, as describe above). Valid values are "None", empty string (""), or a valid IP address. Setting this to "None" makes a "headless service" (no virtual IP), which is useful when direct endpoint connections are preferred and proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. If this field is specified when creating a Service of type ExternalName, creation will fail. This field will be wiped when updating a Service to type ExternalName. If this field is not specified, it will be initialized from the clusterIP field. If this field is specified, clients must ensure that clusterIPs\[0\] and clusterIP have the same value.
///
/// Unless the "IPv6DualStack" feature gate is enabled, this field is limited to one value, which must be the same as the clusterIP field. If the feature gate is enabled, this field may hold a maximum of two entries (dual-stack IPs, in either order). These IPs must correspond to the values of the ipFamilies field. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
pub cluster_i_ps: Option<Vec<String>>,
pub cluster_ips: Option<Vec<String>>,

/// externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.
pub external_ips: Option<Vec<String>>,
Expand Down Expand Up @@ -68,7 +68,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
enum Field {
Key_allocate_load_balancer_node_ports,
Key_cluster_ip,
Key_cluster_i_ps,
Key_cluster_ips,
Key_external_ips,
Key_external_name,
Key_external_traffic_policy,
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
Ok(match v {
"allocateLoadBalancerNodePorts" => Field::Key_allocate_load_balancer_node_ports,
"clusterIP" => Field::Key_cluster_ip,
"clusterIPs" => Field::Key_cluster_i_ps,
"clusterIPs" => Field::Key_cluster_ips,
"externalIPs" => Field::Key_external_ips,
"externalName" => Field::Key_external_name,
"externalTrafficPolicy" => Field::Key_external_traffic_policy,
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
let mut value_allocate_load_balancer_node_ports: Option<bool> = None;
let mut value_cluster_ip: Option<String> = None;
let mut value_cluster_i_ps: Option<Vec<String>> = None;
let mut value_cluster_ips: Option<Vec<String>> = None;
let mut value_external_ips: Option<Vec<String>> = None;
let mut value_external_name: Option<String> = None;
let mut value_external_traffic_policy: Option<String> = None;
Expand All @@ -160,7 +160,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
match key {
Field::Key_allocate_load_balancer_node_ports => value_allocate_load_balancer_node_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_cluster_ip => value_cluster_ip = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_cluster_i_ps => value_cluster_i_ps = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_cluster_ips => value_cluster_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_external_ips => value_external_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_external_name => value_external_name = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_external_traffic_policy => value_external_traffic_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
Expand All @@ -183,7 +183,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
Ok(ServiceSpec {
allocate_load_balancer_node_ports: value_allocate_load_balancer_node_ports,
cluster_ip: value_cluster_ip,
cluster_i_ps: value_cluster_i_ps,
cluster_ips: value_cluster_ips,
external_ips: value_external_ips,
external_name: value_external_name,
external_traffic_policy: value_external_traffic_policy,
Expand Down Expand Up @@ -236,7 +236,7 @@ impl crate::serde::Serialize for ServiceSpec {
"ServiceSpec",
self.allocate_load_balancer_node_ports.as_ref().map_or(0, |_| 1) +
self.cluster_ip.as_ref().map_or(0, |_| 1) +
self.cluster_i_ps.as_ref().map_or(0, |_| 1) +
self.cluster_ips.as_ref().map_or(0, |_| 1) +
self.external_ips.as_ref().map_or(0, |_| 1) +
self.external_name.as_ref().map_or(0, |_| 1) +
self.external_traffic_policy.as_ref().map_or(0, |_| 1) +
Expand All @@ -259,7 +259,7 @@ impl crate::serde::Serialize for ServiceSpec {
if let Some(value) = &self.cluster_ip {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterIP", value)?;
}
if let Some(value) = &self.cluster_i_ps {
if let Some(value) = &self.cluster_ips {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterIPs", value)?;
}
if let Some(value) = &self.external_ips {
Expand Down
16 changes: 8 additions & 8 deletions src/v1_21/api/core/v1/service_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct ServiceSpec {
/// ClusterIPs is a list of IP addresses assigned to this service, and are usually assigned randomly. If an address is specified manually, is in-range (as per system configuration), and is not in use, it will be allocated to the service; otherwise creation of the service will fail. This field may not be changed through updates unless the type field is also being changed to ExternalName (which requires this field to be empty) or the type field is being changed from ExternalName (in which case this field may optionally be specified, as describe above). Valid values are "None", empty string (""), or a valid IP address. Setting this to "None" makes a "headless service" (no virtual IP), which is useful when direct endpoint connections are preferred and proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. If this field is specified when creating a Service of type ExternalName, creation will fail. This field will be wiped when updating a Service to type ExternalName. If this field is not specified, it will be initialized from the clusterIP field. If this field is specified, clients must ensure that clusterIPs\[0\] and clusterIP have the same value.
///
/// Unless the "IPv6DualStack" feature gate is enabled, this field is limited to one value, which must be the same as the clusterIP field. If the feature gate is enabled, this field may hold a maximum of two entries (dual-stack IPs, in either order). These IPs must correspond to the values of the ipFamilies field. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
pub cluster_i_ps: Option<Vec<String>>,
pub cluster_ips: Option<Vec<String>>,

/// externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.
pub external_ips: Option<Vec<String>>,
Expand Down Expand Up @@ -74,7 +74,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
enum Field {
Key_allocate_load_balancer_node_ports,
Key_cluster_ip,
Key_cluster_i_ps,
Key_cluster_ips,
Key_external_ips,
Key_external_name,
Key_external_traffic_policy,
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
Ok(match v {
"allocateLoadBalancerNodePorts" => Field::Key_allocate_load_balancer_node_ports,
"clusterIP" => Field::Key_cluster_ip,
"clusterIPs" => Field::Key_cluster_i_ps,
"clusterIPs" => Field::Key_cluster_ips,
"externalIPs" => Field::Key_external_ips,
"externalName" => Field::Key_external_name,
"externalTrafficPolicy" => Field::Key_external_traffic_policy,
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
let mut value_allocate_load_balancer_node_ports: Option<bool> = None;
let mut value_cluster_ip: Option<String> = None;
let mut value_cluster_i_ps: Option<Vec<String>> = None;
let mut value_cluster_ips: Option<Vec<String>> = None;
let mut value_external_ips: Option<Vec<String>> = None;
let mut value_external_name: Option<String> = None;
let mut value_external_traffic_policy: Option<String> = None;
Expand All @@ -172,7 +172,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
match key {
Field::Key_allocate_load_balancer_node_ports => value_allocate_load_balancer_node_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_cluster_ip => value_cluster_ip = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_cluster_i_ps => value_cluster_i_ps = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_cluster_ips => value_cluster_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_external_ips => value_external_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_external_name => value_external_name = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_external_traffic_policy => value_external_traffic_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
Expand All @@ -197,7 +197,7 @@ impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
Ok(ServiceSpec {
allocate_load_balancer_node_ports: value_allocate_load_balancer_node_ports,
cluster_ip: value_cluster_ip,
cluster_i_ps: value_cluster_i_ps,
cluster_ips: value_cluster_ips,
external_ips: value_external_ips,
external_name: value_external_name,
external_traffic_policy: value_external_traffic_policy,
Expand Down Expand Up @@ -254,7 +254,7 @@ impl crate::serde::Serialize for ServiceSpec {
"ServiceSpec",
self.allocate_load_balancer_node_ports.as_ref().map_or(0, |_| 1) +
self.cluster_ip.as_ref().map_or(0, |_| 1) +
self.cluster_i_ps.as_ref().map_or(0, |_| 1) +
self.cluster_ips.as_ref().map_or(0, |_| 1) +
self.external_ips.as_ref().map_or(0, |_| 1) +
self.external_name.as_ref().map_or(0, |_| 1) +
self.external_traffic_policy.as_ref().map_or(0, |_| 1) +
Expand All @@ -279,7 +279,7 @@ impl crate::serde::Serialize for ServiceSpec {
if let Some(value) = &self.cluster_ip {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterIP", value)?;
}
if let Some(value) = &self.cluster_i_ps {
if let Some(value) = &self.cluster_ips {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterIPs", value)?;
}
if let Some(value) = &self.external_ips {
Expand Down
Loading

0 comments on commit 2e2e6c3

Please sign in to comment.