Releases: Arnavion/k8s-openapi
v0.7.0
-
BREAKING CHANGE: The
http
andbytes
dependencies have been updated. They now match thetokio
0.2 ecosystem. -
BREAKING CHANGE: The
Resource
trait'sapi_version
,group
,kind
andversion
methods are nowAPI_VERSION
,GROUP
,KIND
andVERSION
associated consts of&'static str
type. -
BREAKING CHANGE: The
*List
resource types likePodList
andNodeList
have now been combined into a single generick8s_openapi::List<T>
type. The API response types that contained these list types have been updated accordingly. -
BREAKING CHANGE: The optional parameters of create and replace operations are now emitted as a single common type -
k8s_openapi::CreateOptional
andk8s_openapi::ReplaceOptional
respectively. -
BREAKING CHANGE: The response types of create, delete, delete-collection, list, patch, replace and watch operations have now been combined into generic
CreateResponse<T>
,DeleteResponse<T>
,DeleteResponse<List<T>>
,ListResponse<T>
,PatchResponse<T>
,ReplaceResponse<T>
andWatchResponse<T>
types respectively. -
BUGFIX: v1.16's
k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::JSONSchemaPropsOrArray
,JSONSchemaPropsOrBool
andJSONSchemaPropsOrStringArray
types are now generated correctly, just like theirv1beta
cousins. -
FEATURE: Added support for Kubernetes 1.17 under the
v1_17
feature. -
FEATURE: A new
k8s_openapi::ListableResource
trait has been added to connect a resource type likePod
to its corresponding list type likePodList
. Currently the trait only has one member - an associated constLIST_KIND
that is the same as the list type'sResource::KIND
.
Here are some demonstrative examples of the API changes:
Pod::delete_namespaced_pod
used to returnDeleteNamespacedPodResponse
. It now returnsDeleteResponse<Self>
.Pod::delete_collection_namespaced_pod
used to returnDeleteCollectionNamespacedPodResponse
. It now returnsDeleteResponse<List<Self>>
.Pod::list_namespaced_pod
used to returnListNamespacedPodResponse
which had anOk(PodList)
variant. It now returnsListResponse<Self>
, which has anOk(List<Self>)
variant.
Combining these response types has reduced the compile time and memory usage of the Rust compiler when compiling this crate. Notably, the compiler's memory usage now peaks at ~3 GiB from its earlier ~5 GiB, making it easier to use with environments limited to 4 GiB RAM, like CI VMs and Raspberry Pi's.
Corresponding Kubernetes API server versions:
- v1.8.15
- v1.9.11
- v1.10.13
- v1.11.10
- v1.12.10
- v1.13.12
- v1.14.10
- v1.15.9
- v1.16.6
- v1.17.2
v0.6.0
-
BREAKING CHANGE: Updated
url
dependency, and thus the re-export, to v2. The re-export is only used internally by code-generated API functions and is not part of any public signatures, so it is only a breaking change for you if you were also using it for your own code. -
FEATURE: Added support for Kubernetes 1.16 under the
v1_16
feature. -
FEATURE: The
k8s-openapi-derive
crate is now out of beta.
Corresponding Kubernetes API server versions:
- v1.8.15
- v1.9.11
- v1.10.13
- v1.11.10
- v1.12.10
- v1.13.12
- v1.14.8
- v1.15.5
- v1.16.2
v0.5.1
- FEATURE: The
k8s-openapi
crate now has a default-enabled feature namedapi
. If the feature is disabled, the library will only contain the resource types likeapi::core::v1::Pod
and not the associated operation functions likeapi::core::v1::Pod::read_namespaced_pod
. The correspondingResponse
andOptional
types will also not be accessible. If your crate does not need the operation functions, you can disable this feature to save on compile time and resources.
Corresponding Kubernetes API server versions:
- v1.8.15
- v1.9.11
- v1.10.13
- v1.11.10
- v1.12.10
- v1.13.10
- v1.14.6
- v1.15.3
v0.5.0
-
BREAKING CHANGE: The optional parameters of delete, list, patch and watch operations are now emitted as a single common type -
k8s_openapi::DeleteOptional
,k8s_openapi::ListOptional
,k8s_openapi::PatchOptional
andk8s_openapi::WatchOptional
respectively. For example, where an operation likek8s_openapi::api::core::v1::Pod::list_namespaced_pod
used to have anoptional: k8s_openapi::api::core::v1::ListNamespacedPodOptional<'_>
, it now has anoptional: k8s_openapi::ListOptional<'_>
parameter instead.This is because these per-operation optional structs all had the same members.
Furthermore, delete-collection operations like
Pod::delete_collection_namespaced_pod
now take two optional parameters, one of typek8s_openapi::ListOptional
that determines which items will be selected for deletion, and the other of typek8s_openapi::DeleteOptional
which determines how the selected items will be deleted. -
BREAKING CHANGE: Most response types had an empty
Unauthorized
variant, and did not have other useful variants likeForbidden
orConflict
. To handle those variants, you would have had to match on the emptyOther
variant and manually parse the response body into a JSON value.Now these empty variants like
Unauthorized
are no longer emitted, and the previously emptyOther
variant is now emitted asOther(Result<Option<serde_json::Value>, Error>)
. If the response body is empty, the response will be parsed asOther(Ok(None))
. Otherwise, it will be parsed as JSON intoOther(Ok(Some(response)))
orOther(Err(err))
. -
BREAKING CHANGE: The
apimachinery::pkg::apis::meta::v1::Patch
type used to be incorrectly emitted as an empty struct. It is now emitted as an enum with variants corresponding to the three types of patches supported by Kubernetes -Json(Vec<serde_json::Value>)
,Merge(serde_json::Value)
andStrategicMerge(serde_json::Value)
. -
BREAKING CHANGE: The
apimachinery::pkg::apis::meta::v1::WatchEvent
type used to be emitted as a struct containing a weakly-typedobject
and stringly-typedtype_
fields. It is now generic on the type of object and is emitted asenum WatchEvent<T>
withAdded(T)
,Deleted(T)
,Modified(T)
,ErrorStatus(metav1::Status)
andErrorOther(RawExtension)
members. For v1.15 and above, the enum also has aBookmark(T)
variant. -
BREAKING CHANGE: The
apiextensions_apiserver::pkg::apis::apiextensions::v1beta1::CustomResourceSubresourceStatus
type used to be incorrectly emitted as an empty struct. It is now emitted as a newtype aroundserde_json::Value
-
BREAKING CHANGE: The connect and exec operations on
Node
,Pod
andService
no longer have a corresponding response type. The response types were bogus, and these operations are not HTTP requests but SPDY or WebSocket requests anyway. The functions still returnhttp::Request
, and you will need to decompose these into types that your SPDY / WebSocket crate uses. -
BUGFIX: Operation parameters that were used as path components of the request URL (such as
namespace
) are now correctly encoded instead of being used verbatim. -
FEATURE: The
http::Request
returned by API operation functions now has theContent-Type
header set if the request has a body. Particularly for patch operations, this sets the correctContent-Type
header corresponding to the type of patch used. -
FEATURE: A new crate
k8s-openapi-derive
is now released. This crate contains a custom derive that can be used on a CRD spec type to generate the corresponding CRD type, itsk8s_openapi::Resource
andk8s_openapi::Metadata
impls, and CRUD operations. See that crate's docs for more details.
Corresponding Kubernetes API server versions:
- v1.8.15
- v1.9.11
- v1.10.13
- v1.11.10
- v1.12.10
- v1.13.8
- v1.14.4
- v1.15.1
v0.4.0
-
A new
Resource
trait is implemented on all resource types to get their API version, group, kind and version properties. See docs for details.Since the API version and kind of resource types is statically associated with their Rust types, the
api_version
andkind
fields have been removed from these types. The fields are serialized and deserialized automatically without needing to be set. -
A new
Metadata
trait is implemented on all resource types that have metadata (ObjectMeta
orListMeta
), and can be used to get access to this metadata. -
Fixed string responses like
ReadNamespacedPodLogResponse
to returnResponseError::NeedMoreData
when given an empty slice, instead of returning an empty string. -
Fixed string responses like
ReadNamespacedPodLogResponse
to return as much data as possible before an invalid utf-8 sequence in the input slice. In the previous release, the parser would returnErr
even if there was valid utf-8 before the first invalid byte. It now only returnsErr
if the first byte of the slice is invalid. -
A new
ResponseBody::advance
function can be used to remove bytes from the front of theResponseBody
's internal buffer. This is useful in cases like reading a pod's logs, where the parser indicates that some bytes in the beginning of the slice are invalid, and you want to skip over them and continue parsing.
There are many breaking changes in this release, as part of modifying the generated code to be easier and safer to use:
-
The crate no longer supports enabling multiple version features ('v1_8', 'v1_9', etc). One and only one version feature can be enabled.
As before, it's recommended that only application crates enable features of this crate in their
Cargo.toml
, based on the version of Kubernetes they want to run against. Library crates should not enable specific features. If library crates need to emit different code based on the feature that gets enabled, they should continue to use the version detection macros (k8s_if_ge_1_8! { }
, etc) around such code.The build script of this crate will panic and fail the build if it detects zero or more than one feature has been enabled.
-
In the previous release, every enabled version was represented by a top-level module, eg enabling the
v1_8
feature granted access to thek8s_openapi::v1_8
module and thek8s_openapi::v1_8::api::core::v1::Pod
type. Since only one feature can be enabled now, the contents of this corresponding module are re-exported from the crate root, and the module itself is hidden. Thus enabling thev1_8
feature allows access to v1.8'sPod
type through thek8s_openapi::api::core::v1::Pod
path. This means crates that support multiple versions no longer need to write code like:k8s_if_1_8! { use k8s_openapi::v1_8::api::core::v1 as api; } k8s_if_1_9! { use k8s_openapi::v1_9::api::core::v1 as api; } k8s_if_1_10! { use k8s_openapi::v1_10::api::core::v1 as api; } ...
and can instead write:
use k8s_openapi::api::core::v1 as api;
-
Support for v1.7 API servers has been dropped. Its API structure was very different from the later versions (upstream rearranged the OpenAPI spec in v1.8). Continuing to support it would've required crates to continue using
k8s_if_1_7! { }
andk8s_if_ge_1_7! { }
. By dropping support for it, there is much less reason to use the version detection macros. -
API operation functions now have shorter names in many cases. For example
Pod::read_core_v1_namespaced_pod_log
is now called justPod::read_namespaced_pod_log
. The thing that is stripped from the name is a combination of the API kind ("core") and the API version ("v1"). In general, this means supporting different versions of API, like supportingDeployment::list_apps_v1beta2_namespaced_deployment
on v1.8 andDeployment::list_apps_v1_namespaced_deployment
on v1.9+ no longer requires version detection macros, since the function is now calledDeployment::list_namespaced_deployment
in both cases. -
API operations now take a single parameter for all optional parameters. This parameter implements
Default
such that passing inDefault::default()
for this parameter is equivalent to not passing any optional parameters.For example, the
api::core::v1::Pod::list_namespaced_pod
operation has one required parameter for thenamespace
, and the optional parameters are fields of theapi::core::v1::ListNamespacedPodOptional
struct which is taken as the last parameter of the function. To set one or more of these optional parameters, use struct update syntax to set those parameters andDefault
the rest. See the crate docs for details.This reduces the number of
None
parameters that need to be passed to all operation functions. It also means that function that differed in the number of optional parameters between Kubernetes versions no longer need version detection macros if you don't want to set any of the optional parameters. For example,Job::create_namespaced_job
takes one optional parameter in v1.11 and three in v1.12. With this release, it can be called asJob::create_namespaced_job("name", &spec, Default::default())
regardless of the version. -
ResponseBody
is now generic on the response type at the type level. Previously only itsappend_slice_and_parse
function was generic on the response type. -
ResponseBody::append_slice_and_parse
has been removed. This function gave the wrong impression that appending a slice would allow zero or one responses to be parsed from its buffer. In fact, more than one response can be parsed, say when parsing a sequence ofWatchEvent
s and the appended slice contains more than oneWatchEvent
. Instead, there are now separateResponseBody::append_slice
andResponseBody::parse
functions. You should callResponseBody::parse
in a loop as long as it returnsOk(parsed_response)
. -
API operation functions now return two values in a tuple. The first value is the same
http::Request<Vec<u8>>
that they used to return in the previous release - this is the HTTP request with the path, query string and request body filled out according to the API operation. The second value is a function with the signaturefn(http::StatusCode) -> ResponseBody<ResponseType>
, whereResponseType
is the type that should be used to parse the response. For example,Pod::list_namespaced_pod
returns(http::Request<Vec<u8>>, fn(http::StatusCode) -> ResponseBody<ListNamespacedPodResponse>)
.In previous releases, you would've needed to read the docs to know that
ListNamespacedPodResponse
is the type you should use to parse the response. With this change, you can use the constructor to let the type system enforce it. -
API operations that allowed you to list or watch in the same operation are now more strongly typed. For example, in the previous release,
Pod::list_core_v1_namespaced_pod
's docs indicated that you should useListCoreV1NamespacedPodResponse
to parse its response. However, this function has an optionalwatch
parameter which can be used to get a stream ofWatchEvent
responses instead and thus you would need to parse the response withWatchCoreV1NamespacedPodResponse
instead. ThisWatchCoreV1NamespacedPodResponse
type was the response type of the otherwise unrelatedPod::watch_core_v1_namespaced_pod
operation.Furthermore, Kubernetes has deprecated many of these watch and watchlist operations, like
Pod::watch_core_v1_namespaced_pod
andPod::watch_core_v1_namespaced_pod_list
respectively, in favor of using thelist
operation with thewatch
parameter set.With this release, both of these issues are solved.
The list function, like
Pod::list_namespaced_pod
, no longer has awatch
parameter. This function always returns a list response.The watch function, like
Pod::watch_namespaced_pod
, is no longer generated from the (potentially deprecated) watch function in the OpenAPI spec. Instead, it has the same URL and parameters as thelist
operation. It too does not have awatch
parameter, but it setswatch=true
in the URL of the generatedhttp::Request
automatically. This function always returns aWatchEvent
stream response.The watchlist function, if any, is no longer emitted. It is redundant with the watch function, since watching a single item for changes or multiple items for changes is determined by the specificity of the
field_selector
parameter.
Corresponding Kubernetes API server versions:
- v1.8.15
- v1.9.11
- v1.10.13
- v1.11.8
- v1.12.6
- v1.13.4
v0.3.0
v0.2.0
-
BREAKING CHANGE: Types that were previously emitted as type aliases are now emitted as newtypes. For example
io.k8s.apimachinery.pkg.api.resource.Quantity
was previous emitted aspub type Quantity = String;
but is now emitted aspub struct Quantity(pub String);
-
BREAKING CHANGE: The
IntOrString
enum in the crate root no longer exists. Previously each version'sio.k8s.apimachinery.pkg.util.intstr.IntOrString
was emitted as a type alias for the root type -pub type IntOrString = ::IntOrString;
. Now they are emitted as the enum themselvespub enum IntOrString { ... }
. This bringsIntOrString
in line with other types likeRawExtension
that have special replacement versions.
Corresponding Kubernetes API server versions:
- v1.7.16
- v1.8.14
- v1.9.9
- v1.10.5
- v1.11.0