Skip to content

Commit

Permalink
Add v1.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnavion committed Aug 13, 2024
1 parent d4400f4 commit f33d49e
Show file tree
Hide file tree
Showing 663 changed files with 122,585 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ v1_27 = []
v1_28 = []
v1_29 = []
v1_30 = []
latest = ["v1_30"]
v1_31 = []
latest = ["v1_31"]
# Enable `schemars::JsonSchema` implementations on resource types.
schemars = ["dep:schemars"]

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
use std::io::Write;

const MIN: usize = 24;
const MAX: usize = 30;
const MAX: usize = 31;

println!("cargo::rerun-if-env-changed=K8S_OPENAPI_ENABLED_VERSION");

Expand Down
2 changes: 1 addition & 1 deletion devenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

session_name='k8s-openapi'
max_version='1.30'
max_version='1.31'

if ! tmux has-session -t "=$session_name"; then
cd "$(dirname "$0")"
Expand Down
27 changes: 27 additions & 0 deletions k8s-openapi-codegen/src/fixups/upstream_bugs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,30 @@ pub(crate) fn v1alpha2_resource_claim_scheduling_status_unsuitable_nodes_merge_s

Err("never applied ResourceClaimSchedulingStatus.unsuitableNodes merge strategy override".into())
}

// `ResourceSliceList` is a list with a standard `metadata: ListMeta` field,
// but the spec thinks it has a `listMeta: ListMeta` field instead.
//
// This fixup fixes the OpenAPI spec so that the type is detected as a list, but actually deserializing the JSON object
// will be broken because there is nothing in the generated code to parse a `"listMeta"` object key as if it was
// `"metadata"`. That would require a bunch of changes in codegen-common, which are not worth it for a single alpha type,
// especially since the API server will presumably be fixed at some point anyway.
//
// Ref: https://github.com/kubernetes/kubernetes/issues/126659
pub(crate) fn v1alpha3_resource_slice_list_metadata(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.resource.v1alpha3.ResourceSliceList".to_owned());
if let Some(definition) = spec.definitions.get_mut(&definition_path) {
if let crate::swagger20::SchemaKind::Properties(properties) = &mut definition.kind {
if let Some(property) = properties.remove("listMeta") {
let metadata = properties.insert(crate::swagger20::PropertyName("metadata".to_owned()), property);
if metadata.is_some() {
return Err("ResourceSliceList has both listMeta and metadata properties".into());
}

return Ok(());
}
}
}

Err("never applied ResourceSliceList.metadata field rename override".into())
}
19 changes: 19 additions & 0 deletions k8s-openapi-codegen/src/supported_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub(crate) const ALL: &[SupportedVersion] = &[
SupportedVersion::V1_28,
SupportedVersion::V1_29,
SupportedVersion::V1_30,
SupportedVersion::V1_31,
];

#[derive(Clone, Copy, Debug)]
Expand All @@ -17,6 +18,7 @@ pub(crate) enum SupportedVersion {
V1_28,
V1_29,
V1_30,
V1_31,
}

impl SupportedVersion {
Expand All @@ -29,6 +31,7 @@ impl SupportedVersion {
SupportedVersion::V1_28 => "1.28",
SupportedVersion::V1_29 => "1.29",
SupportedVersion::V1_30 => "1.30",
SupportedVersion::V1_31 => "1.31",
}
}

Expand All @@ -41,6 +44,7 @@ impl SupportedVersion {
SupportedVersion::V1_28 => "v1_28",
SupportedVersion::V1_29 => "v1_29",
SupportedVersion::V1_30 => "v1_30",
SupportedVersion::V1_31 => "v1_31",
}
}

Expand All @@ -53,6 +57,7 @@ impl SupportedVersion {
SupportedVersion::V1_28 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.28.12/api/openapi-spec/swagger.json",
SupportedVersion::V1_29 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.29.7/api/openapi-spec/swagger.json",
SupportedVersion::V1_30 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.30.3/api/openapi-spec/swagger.json",
SupportedVersion::V1_31 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.31.0/api/openapi-spec/swagger.json",
}
}

Expand Down Expand Up @@ -176,6 +181,20 @@ impl SupportedVersion {
crate::fixups::upstream_bugs::required_properties::validating_admission_policy_list,
crate::fixups::upstream_bugs::status_extra_gvk,
],

SupportedVersion::V1_31 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::config_map_env_source,
crate::fixups::upstream_bugs::required_properties::config_map_key_selector,
crate::fixups::upstream_bugs::required_properties::config_map_projection,
crate::fixups::upstream_bugs::required_properties::config_map_volume_source,
crate::fixups::upstream_bugs::required_properties::local_object_reference,
crate::fixups::upstream_bugs::required_properties::secret_env_source,
crate::fixups::upstream_bugs::required_properties::secret_key_selector,
crate::fixups::upstream_bugs::required_properties::secret_projection,
crate::fixups::upstream_bugs::v1alpha3_resource_slice_list_metadata,
],
};

let special_fixups = &[
Expand Down
1 change: 1 addition & 0 deletions k8s-openapi-tests-macro-deps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ test_v1_27 = ["k8s-openapi/v1_27"]
test_v1_28 = ["k8s-openapi/v1_28"]
test_v1_29 = ["k8s-openapi/v1_29"]
test_v1_30 = ["k8s-openapi/v1_30"]
test_v1_31 = ["k8s-openapi/v1_31"]
1 change: 1 addition & 0 deletions k8s-openapi-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ test_v1_27 = ["k8s-openapi/v1_27"]
test_v1_28 = ["k8s-openapi/v1_28"]
test_v1_29 = ["k8s-openapi/v1_29"]
test_v1_30 = ["k8s-openapi/v1_30"]
test_v1_31 = ["k8s-openapi/v1_31"]
2 changes: 1 addition & 1 deletion k8s-openapi-tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
// Assert that the DEP_K8S_OPENAPI_*_VERSION is set by the k8s-openapi crate's build script correctly.

const MIN: usize = 24;
const MAX: usize = 30;
const MAX: usize = 31;

let enabled_version = {
let mut enabled_versions = (MIN..=MAX).filter(|v| std::env::var(format!("CARGO_FEATURE_TEST_V1_{v}")).is_ok());
Expand Down
4 changes: 4 additions & 0 deletions k8s-openapi-tests/cluster-configs/v1.31.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
featureGates:
WatchList: true
16 changes: 16 additions & 0 deletions k8s-openapi-tests/src/clientset/list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
use k8s_openapi::serde_json;

#[allow(dead_code)]
pub(crate) fn list_cluster<T>() -> (http::Request<Vec<u8>>, fn(reqwest::StatusCode) -> super::ResponseBody<ListResponse<T>>)
where
T: serde::de::DeserializeOwned + k8s_openapi::Resource<Scope = k8s_openapi::ClusterResourceScope> + k8s_openapi::ListableResource,
{
let first_segment = if T::GROUP.is_empty() { "api" } else { "apis" };
let url = format!("/{first_segment}/{api_version}/{url_path_segment}",
api_version = T::API_VERSION,
url_path_segment = T::URL_PATH_SEGMENT,
);

let request = http::Request::get(url);
let request = request.body(vec![]).unwrap();
(request, super::ResponseBody::new)
}

pub(crate) fn list_namespaced<T>(
namespace: &str,
) -> (http::Request<Vec<u8>>, fn(reqwest::StatusCode) -> super::ResponseBody<ListResponse<T>>)
Expand Down
4 changes: 3 additions & 1 deletion k8s-openapi-tests/src/clientset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ mod delete_collection;
pub(crate) use delete_collection::{delete_collection_namespaced, ListOptional};

mod list;
pub(crate) use list::{list_namespaced, ListResponse};
#[allow(unused_imports)]
pub(crate) use list::{list_cluster, list_namespaced, ListResponse};

mod patch;
pub(crate) use patch::{patch_namespaced, PatchResponse};
Expand Down Expand Up @@ -47,6 +48,7 @@ impl<T> ResponseBody<T> where T: Response {
}

pub(crate) fn parse(&mut self) -> Result<T, ResponseError> {
println!("===== [{}]", self.buf.escape_ascii());
match T::try_from_parts(self.status_code, &self.buf) {
Ok((result, read)) => {
self.advance(read);
Expand Down
3 changes: 2 additions & 1 deletion k8s-openapi-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl Client {
#[cfg(feature = "test_v1_28")] let replays_directory = "v1-28";
#[cfg(feature = "test_v1_29")] let replays_directory = "v1-29";
#[cfg(feature = "test_v1_30")] let replays_directory = "v1-30";
#[cfg(feature = "test_v1_31")] let replays_directory = "v1-31";

let replays_directory =
std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR")))
Expand Down Expand Up @@ -214,7 +215,7 @@ impl Client {
url.path_and_query = Some(path);
let url = http::Uri::from_parts(url).expect("couldn't parse URL from parts");

let request = inner.request(method, url.to_string());
let request = inner.request(method, dbg!(url.to_string()));
let request =
if let Some(content_type) = content_type {
request.header(reqwest::header::CONTENT_TYPE, content_type)
Expand Down
10 changes: 10 additions & 0 deletions k8s-openapi-tests/test-replays/v1-31/api_versions-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"request_url": "/apis",
"request_method": "GET",
"request_body": "",
"request_content_type": null,
"response_status_code": 200,
"response_body": "{\"kind\":\"APIGroupList\",\"apiVersion\":\"v1\",\"groups\":[{\"name\":\"apiregistration.k8s.io\",\"versions\":[{\"groupVersion\":\"apiregistration.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"apiregistration.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"apps\",\"versions\":[{\"groupVersion\":\"apps/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"apps/v1\",\"version\":\"v1\"}},{\"name\":\"events.k8s.io\",\"versions\":[{\"groupVersion\":\"events.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"events.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"authentication.k8s.io\",\"versions\":[{\"groupVersion\":\"authentication.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"authentication.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"authorization.k8s.io\",\"versions\":[{\"groupVersion\":\"authorization.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"authorization.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"autoscaling\",\"versions\":[{\"groupVersion\":\"autoscaling/v2\",\"version\":\"v2\"},{\"groupVersion\":\"autoscaling/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"autoscaling/v2\",\"version\":\"v2\"}},{\"name\":\"batch\",\"versions\":[{\"groupVersion\":\"batch/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"batch/v1\",\"version\":\"v1\"}},{\"name\":\"certificates.k8s.io\",\"versions\":[{\"groupVersion\":\"certificates.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"certificates.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"networking.k8s.io\",\"versions\":[{\"groupVersion\":\"networking.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"networking.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"policy\",\"versions\":[{\"groupVersion\":\"policy/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"policy/v1\",\"version\":\"v1\"}},{\"name\":\"rbac.authorization.k8s.io\",\"versions\":[{\"groupVersion\":\"rbac.authorization.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"rbac.authorization.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"storage.k8s.io\",\"versions\":[{\"groupVersion\":\"storage.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"storage.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"admissionregistration.k8s.io\",\"versions\":[{\"groupVersion\":\"admissionregistration.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"admissionregistration.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"apiextensions.k8s.io\",\"versions\":[{\"groupVersion\":\"apiextensions.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"apiextensions.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"scheduling.k8s.io\",\"versions\":[{\"groupVersion\":\"scheduling.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"scheduling.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"coordination.k8s.io\",\"versions\":[{\"groupVersion\":\"coordination.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"coordination.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"node.k8s.io\",\"versions\":[{\"groupVersion\":\"node.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"node.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"discovery.k8s.io\",\"versions\":[{\"groupVersion\":\"discovery.k8s.io/v1\",\"version\":\"v1\"}],\"preferredVersion\":{\"groupVersion\":\"discovery.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"flowcontrol.apiserver.k8s.io\",\"versions\":[{\"groupVersion\":\"flowcontrol.apiserver.k8s.io/v1\",\"version\":\"v1\"},{\"groupVersion\":\"flowcontrol.apiserver.k8s.io/v1beta3\",\"version\":\"v1beta3\"}],\"preferredVersion\":{\"groupVersion\":\"flowcontrol.apiserver.k8s.io/v1\",\"version\":\"v1\"}},{\"name\":\"resource.k8s.io\",\"versions\":[{\"groupVersion\":\"resource.k8s.io/v1alpha3\",\"version\":\"v1alpha3\"}],\"preferredVersion\":{\"groupVersion\":\"resource.k8s.io/v1alpha3\",\"version\":\"v1alpha3\"}}]}\n"
}
]
Loading

0 comments on commit f33d49e

Please sign in to comment.