Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[versioned(
version(name = "v1alpha1"),
k8s(group = "stackable.tech", shortname = "f", shortname = "fo",)
)]
// ---
#[derive(
Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema, kube::CustomResource,
)]
pub(crate) struct FooSpec {}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions crates/stackable-versioned-macros/src/attrs/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use syn::Path;
/// - `namespaced`, to specify that this is a namespaced resource rather than cluster level.
/// - `crates`: Override specific crates.
/// - `status`: Sets the specified struct as the status subresource.
/// - `shortname`: Sets the shortname of the CRD.
/// - `shortname`: Sets one or more shortnames for the CRD.
/// - `skip`, which controls skipping parts of the generation.
#[derive(Clone, Debug, FromMeta)]
pub(crate) struct KubernetesArguments {
Expand All @@ -32,7 +32,8 @@ pub(crate) struct KubernetesArguments {
// schema
// scale
// printcolumn
pub(crate) shortname: Option<String>,
#[darling(multiple, rename = "shortname")]
pub(crate) shortnames: Vec<String>,
// category
// selectable
// doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub(crate) struct KubernetesOptions {
// schema
// scale
// printcolumn
pub(crate) shortname: Option<String>,
pub(crate) shortnames: Vec<String>,
// category
// selectable
// doc
Expand All @@ -301,7 +301,7 @@ impl From<KubernetesArguments> for KubernetesOptions {
.crates
.map_or_else(KubernetesCrateOptions::default, |crates| crates.into()),
status: args.status,
shortname: args.shortname,
shortnames: args.shortnames,
skip_merged_crd: args.skip.map_or(false, |s| s.merged_crd.is_present()),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ impl Struct {
.status
.as_ref()
.map(|s| quote! { , status = #s });
let shortname = kubernetes_options
.shortname
.as_ref()
.map(|s| quote! { , shortname = #s });
let shortnames: TokenStream = kubernetes_options
.shortnames
.iter()
.map(|s| quote! { , shortname = #s })
.collect();

Some(quote! {
// The end-developer needs to derive CustomResource and JsonSchema.
Expand All @@ -294,7 +295,7 @@ impl Struct {
// These must be comma separated (except the last) as they always exist:
group = #group, version = #version, kind = #kind
// These fields are optional, and therefore the token stream must prefix each with a comma:
#singular #plural #namespaced #crates #status #shortname
#singular #plural #namespaced #crates #status #shortnames
)]
})
}
Expand Down
6 changes: 6 additions & 0 deletions crates/stackable-versioned/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Add support for multiple k8s `shortname` arguments ([#958]).

[#958]: https://github.com/stackabletech/operator-rs/pull/958

## [0.5.0] - 2024-12-03

### Added
Expand Down