Skip to content

Commit

Permalink
Add v1.28.1
Browse files Browse the repository at this point in the history
Fixes #145
  • Loading branch information
Arnavion committed Sep 2, 2023
1 parent 40f2892 commit 7a0e1b4
Show file tree
Hide file tree
Showing 601 changed files with 110,811 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ K8S_RECORD=1 ./test.sh all run-tests

`diff` the mod root of the previous version and the new one to see precisely what changed between the two versions. This is useful to discover new fixups that could be backported to older versions.

1. Search for `_[a-z]s:` to find new special idents that need to be handled in `get_rust_ident`. If found, handle them, and add tests in `fn special_idents`

1. `/Cargo.toml`: Add a new feature for the new version.

1. `/Cargo.toml`: Update `latest` feature to the new feature.
Expand Down Expand Up @@ -89,8 +91,6 @@ K8S_RECORD=1 ./test.sh all run-tests
./test.sh '...' run-tests
```

1. `/.github/workflows/ci.yaml`: Add a new `strategy` for the new version.

1. `/devenv.sh`: Update `max_version`.


Expand Down
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_24 = []
v1_25 = []
v1_26 = []
v1_27 = []
latest = ["v1_27"]
v1_28 = []
latest = ["v1_28"]

[package.metadata.docs.rs]
# docs.rs generates docs for the latest version. To see the docs for an older version, please generate them yourself.
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 = 22;
const MAX: usize = 27;
const MAX: usize = 28;

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.27'
max_version='1.28'

if ! tmux has-session -t "=$session_name"; then
cd "$(dirname "$0")"
Expand Down
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 @@ -1151,6 +1151,7 @@ pub fn get_rust_ident(name: &str) -> std::borrow::Cow<'static, str> {
match name {
"clusterIPs" => return "cluster_ips".into(),
"externalIPs" => return "external_ips".into(),
"hostIPs" => return "host_ips".into(),
"nonResourceURLs" => return "non_resource_urls".into(),
"podCIDRs" => return "pod_cidrs".into(),
"podIPs" => return "pod_ips".into(),
Expand Down
42 changes: 38 additions & 4 deletions k8s-openapi-codegen/src/fixups/upstream_bugs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub(crate) mod optional_properties {
// Override it to be required.
pub(crate) mod required_properties {
// `ValidatingAdmissionPolicyBindingList::items`
pub(crate) fn validating_admission_policy_binding_list(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
pub(crate) fn alpha1_validating_admission_policy_binding_list(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.admissionregistration.v1alpha1.ValidatingAdmissionPolicyBindingList".to_owned());
if let Some(definition) = spec.definitions.get_mut(&definition_path) {
if let crate::swagger20::SchemaKind::Properties(properties) = &mut definition.kind {
Expand All @@ -106,11 +106,11 @@ pub(crate) mod required_properties {
}
}

Err("never applied ValidatingAdmissionPolicyBindingList required properties override".into())
Err("never applied admissionregistration.k8s.io/v1alpha1.ValidatingAdmissionPolicyBindingList required properties override".into())
}

// `ValidatingAdmissionPolicyList::items`
pub(crate) fn validating_admission_policy_list(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
pub(crate) fn alpha1_validating_admission_policy_list(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.admissionregistration.v1alpha1.ValidatingAdmissionPolicyList".to_owned());
if let Some(definition) = spec.definitions.get_mut(&definition_path) {
if let crate::swagger20::SchemaKind::Properties(properties) = &mut definition.kind {
Expand All @@ -123,7 +123,41 @@ pub(crate) mod required_properties {
}
}

Err("never applied ValidatingAdmissionPolicyList required properties override".into())
Err("never applied admissionregistration.k8s.io/v1alpha1.ValidatingAdmissionPolicyList required properties override".into())
}

// `ValidatingAdmissionPolicyBindingList::items`
pub(crate) fn beta1_validating_admission_policy_binding_list(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.admissionregistration.v1beta1.ValidatingAdmissionPolicyBindingList".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.get_mut("items") {
if !property.1 {
property.1 = true;
return Ok(());
}
}
}
}

Err("never applied admissionregistration.k8s.io/v1beta1.ValidatingAdmissionPolicyBindingList required properties override".into())
}

// `ValidatingAdmissionPolicyList::items`
pub(crate) fn beta1_validating_admission_policy_list(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.admissionregistration.v1beta1.ValidatingAdmissionPolicyList".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.get_mut("items") {
if !property.1 {
property.1 = true;
return Ok(());
}
}
}
}

Err("never applied admissionregistration.k8s.io/v1beta1.ValidatingAdmissionPolicyList required properties override".into())
}
}

Expand Down
23 changes: 19 additions & 4 deletions k8s-openapi-codegen/src/supported_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub(crate) const ALL: &[SupportedVersion] = &[
SupportedVersion::V1_25,
SupportedVersion::V1_26,
SupportedVersion::V1_27,
SupportedVersion::V1_28,
];

#[derive(Clone, Copy, Debug)]
Expand All @@ -15,6 +16,7 @@ pub(crate) enum SupportedVersion {
V1_25,
V1_26,
V1_27,
V1_28,
}

impl SupportedVersion {
Expand All @@ -26,6 +28,7 @@ impl SupportedVersion {
SupportedVersion::V1_25 => "1.25",
SupportedVersion::V1_26 => "1.26",
SupportedVersion::V1_27 => "1.27",
SupportedVersion::V1_28 => "1.28",
}
}

Expand All @@ -37,6 +40,7 @@ impl SupportedVersion {
SupportedVersion::V1_25 => "v1_25",
SupportedVersion::V1_26 => "v1_26",
SupportedVersion::V1_27 => "v1_27",
SupportedVersion::V1_28 => "v1_28",
}
}

Expand All @@ -48,6 +52,7 @@ impl SupportedVersion {
SupportedVersion::V1_25 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.25.13/api/openapi-spec/swagger.json",
SupportedVersion::V1_26 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.26.8/api/openapi-spec/swagger.json",
SupportedVersion::V1_27 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.27.5/api/openapi-spec/swagger.json",
SupportedVersion::V1_28 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.28.1/api/openapi-spec/swagger.json",
}
}

Expand Down Expand Up @@ -80,16 +85,26 @@ impl SupportedVersion {
SupportedVersion::V1_26 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::validating_admission_policy_binding_list,
crate::fixups::upstream_bugs::required_properties::validating_admission_policy_list,
crate::fixups::upstream_bugs::required_properties::alpha1_validating_admission_policy_binding_list,
crate::fixups::upstream_bugs::required_properties::alpha1_validating_admission_policy_list,
crate::fixups::upstream_bugs::status_extra_gvk,
],

SupportedVersion::V1_27 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::validating_admission_policy_binding_list,
crate::fixups::upstream_bugs::required_properties::validating_admission_policy_list,
crate::fixups::upstream_bugs::required_properties::alpha1_validating_admission_policy_binding_list,
crate::fixups::upstream_bugs::required_properties::alpha1_validating_admission_policy_list,
crate::fixups::upstream_bugs::status_extra_gvk,
],

SupportedVersion::V1_28 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::alpha1_validating_admission_policy_binding_list,
crate::fixups::upstream_bugs::required_properties::alpha1_validating_admission_policy_list,
crate::fixups::upstream_bugs::required_properties::beta1_validating_admission_policy_binding_list,
crate::fixups::upstream_bugs::required_properties::beta1_validating_admission_policy_list,
crate::fixups::upstream_bugs::status_extra_gvk,
],
};
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 @@ -22,3 +22,4 @@ test_v1_24 = ["k8s-openapi/v1_24"]
test_v1_25 = ["k8s-openapi/v1_25"]
test_v1_26 = ["k8s-openapi/v1_26"]
test_v1_27 = ["k8s-openapi/v1_27"]
test_v1_28 = ["k8s-openapi/v1_28"]
1 change: 1 addition & 0 deletions k8s-openapi-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ test_v1_24 = ["k8s-openapi/v1_24"]
test_v1_25 = ["k8s-openapi/v1_25"]
test_v1_26 = ["k8s-openapi/v1_26"]
test_v1_27 = ["k8s-openapi/v1_27"]
test_v1_28 = ["k8s-openapi/v1_28"]
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 = 22;
const MAX: usize = 27;
const MAX: usize = 28;

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.28.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
1 change: 1 addition & 0 deletions k8s-openapi-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl Client {
#[cfg(feature = "test_v1_25")] let replays_directory = "v1-25";
#[cfg(feature = "test_v1_26")] let replays_directory = "v1-26";
#[cfg(feature = "test_v1_27")] let replays_directory = "v1-27";
#[cfg(feature = "test_v1_28")] let replays_directory = "v1-28";

let replays_directory =
std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR")))
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 @@ -10,6 +10,9 @@ fn special_idents() {
let _ = api::NodeSpec { pod_cidrs: Default::default(), ..Default::default() };

let _ = api::PodStatus { pod_ips: Default::default(), ..Default::default() };
k8s_openapi::k8s_if_ge_1_28! {
let _ = api::PodStatus { host_ips: Default::default(), ..Default::default() };
}

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

Expand Down
10 changes: 10 additions & 0 deletions k8s-openapi-tests/test-replays/v1-28/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/v1beta3\",\"version\":\"v1beta3\"},{\"groupVersion\":\"flowcontrol.apiserver.k8s.io/v1beta2\",\"version\":\"v1beta2\"}],\"preferredVersion\":{\"groupVersion\":\"flowcontrol.apiserver.k8s.io/v1beta3\",\"version\":\"v1beta3\"}}]}\n"
}
]
Loading

0 comments on commit 7a0e1b4

Please sign in to comment.