Skip to content

Commit

Permalink
Drop support for v1.20 and v1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnavion committed Aug 5, 2023
1 parent 4ed8984 commit 6deb1cf
Show file tree
Hide file tree
Showing 1,367 changed files with 39 additions and 343,576 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:

matrix:
version:
- '1.20'
- '1.21'
- '1.22'
- '1.23'
- '1.24'
Expand Down
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ default = ["api"]
api = ["http", "percent-encoding", "url"] # Enables API operation functions and response types. If disabled, only the resource types will be exported.

# Each feature corresponds to a supported version of Kubernetes
earliest = ["v1_20"]
v1_20 = []
v1_21 = []
earliest = ["v1_22"]
v1_22 = []
v1_23 = []
v1_24 = []
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
use std::io::Write;

const MIN: usize = 20;
const MIN: usize = 22;
const MAX: usize = 27;

println!("cargo:rerun-if-env-changed=K8S_OPENAPI_ENABLED_VERSION");
Expand Down
13 changes: 4 additions & 9 deletions k8s-openapi-codegen/src/fixups/special.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,17 @@ pub(crate) fn remove_delete_operations_query_parameters(spec: &mut crate::swagge
}
}

// Read operations have `exact` and `export` parameters used for server-side export, and a `pretty` parameter to pretty-print the output.
// The first two were removed in 1.21, were deprecated and known to be broken before that, and would've caused the response to not be able to be parsed
// with the corresponding response type anyway. And the third is not useful for programmatic clients. So this fixup removes these parameters.
// Read operations have a `pretty` parameter to pretty-print the output. This is not useful for programmatic clients, so this fixup removes it.
//
// Since almost all read operations have only these parameters, such operations have their optional parameters type eliminated entirely as a result.
// Since almost all read operations have only this parameter, such operations have their optional parameters type eliminated entirely as a result.
// To be precise, the only read operation that still has optional parameters is `readCoreV1NamespacedPodLog`.
pub(crate) fn remove_read_operations_query_parameters(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let mut found = false;

for operation in &mut spec.operations {
if operation.kubernetes_action == Some(crate::swagger20::KubernetesAction::Get) {
operation.parameters.retain(|p| match &*p.name {
"exact" | "export" | "pretty" => { found = true; false }
"pretty" => { found = true; false }
_ => true,
});
}
Expand Down Expand Up @@ -971,10 +969,7 @@ pub(crate) fn response_types(spec: &mut crate::swagger20::Spec) -> Result<(), cr

let mut response_status_codes: Vec<_> = responses.keys().copied().collect();
response_status_codes.sort();
if
response_status_codes != [http::StatusCode::OK, http::StatusCode::CREATED] &&
response_status_codes != [http::StatusCode::OK] // 1.21 and earlier did not have 201
{
if response_status_codes != [http::StatusCode::OK, http::StatusCode::CREATED] {
return Err(format!("operation {} does not have the expected response status codes of a patch operation: {response_status_codes:?}",
operation.id).into());
}
Expand Down
19 changes: 0 additions & 19 deletions k8s-openapi-codegen/src/fixups/upstream_bugs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ pub(crate) fn pod_exec_command_parameter_type(spec: &mut crate::swagger20::Spec)
//
// Override it to be optional to achieve the same effect.
pub(crate) mod optional_properties {
// `ContainerImage::names`
//
// Ref: https://github.com/kubernetes/kubernetes/issues/93606
pub(crate) fn containerimage(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.core.v1.ContainerImage".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("names") {
if property.1 {
property.1 = false;
return Ok(());
}
}
}
}

Err("never applied ContainerImage optional properties override".into())
}

// `Event::eventTime`
pub(crate) fn eventsv1beta1_event(spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
let definition_path = crate::swagger20::DefinitionPath("io.k8s.api.events.v1beta1.Event".to_owned());
Expand Down
6 changes: 3 additions & 3 deletions k8s-openapi-codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ async fn main() -> Result<(), Error> {
struct Options {
/// This parameter specifies the versions of Kubernetes that the API bindings should be generated for.
///
/// `--generate=1.20` means "generate bindings for Kubernetes v1.20,
/// `--generate=1.27` means "generate bindings for Kubernetes v1.27,
/// using that version's OpenAPI spec from the https://github.com/kubernetes/kubernetes repository".
///
/// `--generate=1.20:https://example.org/swagger.json` means "generate bindings for v1.20
/// `--generate=1.27:https://example.org/swagger.json` means "generate bindings for v1.27
/// using the OpenAPI spec at the URL https://example.org/swagger.json".
///
/// `--generate=1.20:file:///path/to/swagger.json` means "generate binding for v1.20,
/// `--generate=1.27:file:///path/to/swagger.json` means "generate binding for v1.27,
/// using the OpenAPI spec in the file /path/to/swagger.json".
///
/// This parameter can be specified multiple times to generate bindings for multiple versions.
Expand Down
26 changes: 0 additions & 26 deletions k8s-openapi-codegen/src/supported_version.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pub(crate) const ALL: &[SupportedVersion] = &[
SupportedVersion::V1_20,
SupportedVersion::V1_21,
SupportedVersion::V1_22,
SupportedVersion::V1_23,
SupportedVersion::V1_24,
Expand All @@ -11,8 +9,6 @@ pub(crate) const ALL: &[SupportedVersion] = &[

#[derive(Clone, Copy, Debug)]
pub(crate) enum SupportedVersion {
V1_20,
V1_21,
V1_22,
V1_23,
V1_24,
Expand All @@ -24,8 +20,6 @@ pub(crate) enum SupportedVersion {
impl SupportedVersion {
pub(crate) fn name(self) -> &'static str {
match self {
SupportedVersion::V1_20 => "1.20",
SupportedVersion::V1_21 => "1.21",
SupportedVersion::V1_22 => "1.22",
SupportedVersion::V1_23 => "1.23",
SupportedVersion::V1_24 => "1.24",
Expand All @@ -37,8 +31,6 @@ impl SupportedVersion {

pub(crate) fn mod_root(self) -> &'static str {
match self {
SupportedVersion::V1_20 => "v1_20",
SupportedVersion::V1_21 => "v1_21",
SupportedVersion::V1_22 => "v1_22",
SupportedVersion::V1_23 => "v1_23",
SupportedVersion::V1_24 => "v1_24",
Expand All @@ -50,8 +42,6 @@ impl SupportedVersion {

pub(crate) fn spec_url(self) -> &'static str {
match self {
SupportedVersion::V1_20 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.20.15/api/openapi-spec/swagger.json",
SupportedVersion::V1_21 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.21.14/api/openapi-spec/swagger.json",
SupportedVersion::V1_22 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.22.17/api/openapi-spec/swagger.json",
SupportedVersion::V1_23 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.23.17/api/openapi-spec/swagger.json",
SupportedVersion::V1_24 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.24.16/api/openapi-spec/swagger.json",
Expand All @@ -64,22 +54,6 @@ impl SupportedVersion {
pub(crate) fn fixup(self, spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
#[allow(clippy::match_same_arms, clippy::type_complexity)]
let upstream_bugs_fixups: &[fn(&mut crate::swagger20::Spec) -> Result<(), crate::Error>] = match self {
SupportedVersion::V1_20 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::containerimage,
crate::fixups::upstream_bugs::optional_properties::eventsv1beta1_event,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::pod_exec_command_parameter_type,
],

SupportedVersion::V1_21 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::containerimage,
crate::fixups::upstream_bugs::optional_properties::eventsv1beta1_event,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::pod_exec_command_parameter_type,
],

SupportedVersion::V1_22 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1beta1_event,
Expand Down
2 changes: 0 additions & 2 deletions k8s-openapi-tests-macro-deps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ k8s-openapi = { path = ".." }
k8s-openapi-derive = { path = "../k8s-openapi-derive" }

[features]
test_v1_20 = ["k8s-openapi/v1_20"]
test_v1_21 = ["k8s-openapi/v1_21"]
test_v1_22 = ["k8s-openapi/v1_22"]
test_v1_23 = ["k8s-openapi/v1_23"]
test_v1_24 = ["k8s-openapi/v1_24"]
Expand Down
2 changes: 0 additions & 2 deletions k8s-openapi-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ tokio = { version = "1", default-features = false, features = [
] }

[features]
test_v1_20 = ["k8s-openapi/v1_20"]
test_v1_21 = ["k8s-openapi/v1_21"]
test_v1_22 = ["k8s-openapi/v1_22"]
test_v1_23 = ["k8s-openapi/v1_23"]
test_v1_24 = ["k8s-openapi/v1_24"]
Expand Down
2 changes: 1 addition & 1 deletion k8s-openapi-tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
fn main() {
// Assert that the DEP_K8S_OPENAPI_*_VERSION is set by the k8s-openapi crate's build script correctly.

const MIN: usize = 20;
const MIN: usize = 22;
const MAX: usize = 27;

let enabled_version = {
Expand Down
2 changes: 0 additions & 2 deletions k8s-openapi-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ struct Replay {

impl Client {
fn new(test_name: &'static str) -> Self {
#[cfg(feature = "test_v1_20")] let replays_directory = "v1-20";
#[cfg(feature = "test_v1_21")] let replays_directory = "v1-21";
#[cfg(feature = "test_v1_22")] let replays_directory = "v1-22";
#[cfg(feature = "test_v1_23")] let replays_directory = "v1-23";
#[cfg(feature = "test_v1_24")] let replays_directory = "v1-24";
Expand Down
26 changes: 1 addition & 25 deletions k8s-openapi-tests/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,14 @@
fn impl_resource() {
assert_is_subresource::<k8s_openapi::api::authentication::v1::TokenRequest>("token");

k8s_openapi::k8s_if_le_1_21! {
assert_is_cluster_scoped::<k8s_openapi::api::authentication::v1beta1::TokenReview>("tokenreviews");
}
assert_is_cluster_scoped::<k8s_openapi::api::authentication::v1::TokenReview>("tokenreviews");

k8s_openapi::k8s_if_le_1_21! {
assert_is_namespace_scoped::<k8s_openapi::api::authorization::v1beta1::LocalSubjectAccessReview>("localsubjectaccessreviews");
}
assert_is_namespace_scoped::<k8s_openapi::api::authorization::v1::LocalSubjectAccessReview>("localsubjectaccessreviews");

k8s_openapi::k8s_if_le_1_21! {
assert_is_cluster_scoped::<k8s_openapi::api::authorization::v1beta1::SelfSubjectAccessReview>("selfsubjectaccessreviews");
}
assert_is_cluster_scoped::<k8s_openapi::api::authorization::v1::SelfSubjectAccessReview>("selfsubjectaccessreviews");

k8s_openapi::k8s_if_le_1_21! {
assert_is_cluster_scoped::<k8s_openapi::api::authorization::v1beta1::SelfSubjectRulesReview>("selfsubjectrulesreviews");
}
assert_is_cluster_scoped::<k8s_openapi::api::authorization::v1::SelfSubjectRulesReview>("selfsubjectrulesreviews");

k8s_openapi::k8s_if_le_1_21! {
assert_is_cluster_scoped::<k8s_openapi::api::authorization::v1beta1::SubjectAccessReview>("subjectaccessreviews");
}
assert_is_cluster_scoped::<k8s_openapi::api::authorization::v1::SubjectAccessReview>("subjectaccessreviews");

assert_is_namespace_scoped::<k8s_openapi::api::authorization::v1::LocalSubjectAccessReview>("localsubjectaccessreviews");
Expand All @@ -41,10 +26,6 @@ fn impl_resource() {

assert_is_namespace_scoped::<k8s_openapi::api::apps::v1::DaemonSet>("daemonsets");

k8s_openapi::k8s_if_1_21! {
assert_is_subresource::<k8s_openapi::api::core::v1::EphemeralContainers>("ephemeralcontainers");
}

assert_is_cluster_scoped::<k8s_openapi::api::core::v1::Namespace>("namespaces");

assert_is_namespace_scoped::<k8s_openapi::api::core::v1::Pod>("pods");
Expand All @@ -59,12 +40,7 @@ fn impl_resource() {

assert_is_subresource::<k8s_openapi::apimachinery::pkg::apis::meta::v1::Status>("status");

k8s_openapi::k8s_if_le_1_21! {
assert_is_subresource::<k8s_openapi::api::policy::v1beta1::Eviction>("eviction");
}
k8s_openapi::k8s_if_ge_1_22! {
assert_is_subresource::<k8s_openapi::api::policy::v1::Eviction>("eviction");
}
assert_is_subresource::<k8s_openapi::api::policy::v1::Eviction>("eviction");

assert_is_cluster_scoped::<k8s_openapi::List<k8s_openapi::api::core::v1::Namespace>>("");
assert_is_namespace_scoped::<k8s_openapi::List<k8s_openapi::api::core::v1::Pod>>("");
Expand Down
22 changes: 7 additions & 15 deletions k8s-openapi-tests/src/special_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@
fn special_idents() {
use k8s_openapi::api::core::v1 as api;
use k8s_openapi::api::authorization::v1 as authorization;
use k8s_openapi::api::rbac::v1 as rbac;
use k8s_openapi::apimachinery::pkg::apis::meta::v1 as meta;

k8s_openapi::k8s_if_le_1_21! {
use k8s_openapi::api::rbac::v1beta1 as rbac;
}

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 _ = api::NodeSpec { pod_cidrs: Default::default(), ..Default::default() };

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

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

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

let _ = meta::APIGroup { server_address_by_client_cidrs: Default::default(), ..Default::default() };

let _ = meta::APIVersions { server_address_by_client_cidrs: Default::default(), ..Default::default() };

k8s_openapi::k8s_if_le_1_21! {
let _ = rbac::PolicyRule { non_resource_urls: Default::default(), ..Default::default() };
}

let _ = api::NodeSpec { pod_cidrs: Default::default(), ..Default::default() };

let _ = api::PodStatus { pod_ips: Default::default(), ..Default::default() };
let _ = rbac::PolicyRule { non_resource_urls: Default::default(), ..Default::default() };
}
10 changes: 0 additions & 10 deletions k8s-openapi-tests/test-replays/v1-20/api_versions-list.json

This file was deleted.

Loading

0 comments on commit 6deb1cf

Please sign in to comment.