Skip to content

Commit 4ee9a30

Browse files
committed
chore: Merge branch 'main' into chore/stackable-versioned-remove-print-write-merged-crd
2 parents d2134f8 + 5dcb07b commit 4ee9a30

File tree

10 files changed

+24
-18
lines changed

10 files changed

+24
-18
lines changed

crates/stackable-versioned-macros/fixtures/inputs/k8s/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#[derive(
1414
Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema, kube::CustomResource,
1515
)]
16-
pub struct FooSpec {
16+
pub(crate) struct FooSpec {
1717
#[versioned(
1818
added(since = "v1beta1"),
1919
changed(since = "v1", from_name = "bah", from_type = "u16")

crates/stackable-versioned-macros/fixtures/snapshots/[email protected]

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@crate_overrides.rs.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-versioned-macros/fixtures/snapshots/[email protected]

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module_preserve.rs.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@renamed_kind.rs.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-versioned-macros/src/codegen/container/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ impl Container {
9393
enum_variant_idents: &[IdentString],
9494
enum_variant_strings: &[String],
9595
fn_calls: &[TokenStream],
96+
vis: &Visibility,
9697
is_nested: bool,
9798
) -> Option<TokenStream> {
9899
match self {
99100
Container::Struct(s) => s.generate_kubernetes_merge_crds(
100101
enum_variant_idents,
101102
enum_variant_strings,
102103
fn_calls,
104+
vis,
103105
is_nested,
104106
),
105107
Container::Enum(_) => None,
@@ -216,6 +218,7 @@ impl StandaloneContainer {
216218
&kubernetes_enum_variant_idents,
217219
&kubernetes_enum_variant_strings,
218220
&kubernetes_merge_crds_fn_calls,
221+
vis,
219222
false,
220223
));
221224

crates/stackable-versioned-macros/src/codegen/container/struct.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ops::Not;
33
use darling::{util::IdentString, Error, FromAttributes, Result};
44
use proc_macro2::TokenStream;
55
use quote::{quote, ToTokens};
6-
use syn::{parse_quote, ItemStruct, Path};
6+
use syn::{parse_quote, ItemStruct, Path, Visibility};
77

88
use crate::{
99
attrs::container::NestedContainerAttributes,
@@ -332,6 +332,7 @@ impl Struct {
332332
enum_variant_idents: &[IdentString],
333333
enum_variant_strings: &[String],
334334
fn_calls: &[TokenStream],
335+
vis: &Visibility,
335336
is_nested: bool,
336337
) -> Option<TokenStream> {
337338
match &self.common.options.kubernetes_options {
@@ -347,10 +348,9 @@ impl Struct {
347348
let k8s_openapi_path = &*kubernetes_options.crates.k8s_openapi;
348349
let kube_core_path = &*kubernetes_options.crates.kube_core;
349350

350-
// TODO (@Techassi): Use proper visibility instead of hard-coding 'pub'
351351
Some(quote! {
352352
#automatically_derived
353-
pub enum #enum_ident {
353+
#vis enum #enum_ident {
354354
#(#enum_variant_idents),*
355355
}
356356

@@ -365,7 +365,7 @@ impl Struct {
365365

366366
#automatically_derived
367367
impl #enum_ident {
368-
/// Generates a merged CRD which contains all versions defined using the `#[versioned()]` macro.
368+
/// Generates a merged CRD containing all versions and marking `stored_apiversion` as stored.
369369
pub fn merged_crd(
370370
stored_apiversion: Self
371371
) -> ::std::result::Result<#k8s_openapi_path::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition, #kube_core_path::crd::MergeError> {

crates/stackable-versioned-macros/src/codegen/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl Module {
137137
kubernetes_enum_variant_idents,
138138
kubernetes_enum_variant_strings,
139139
kubernetes_merge_crds_fn_calls,
140+
version_module_vis,
140141
self.preserve_module,
141142
));
142143
}

crates/stackable-versioned/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66

77
### Added
88

9+
- Use visibility of container definition or module for generated CRD enum ([#923]).
910
- Add support to apply the `#[versioned()]` macro to modules to version all contained items at
1011
once ([#891]).
1112
- Add support for passing a `status`, `crates`, and `shortname` arguments through to the `#[kube]`
@@ -36,6 +37,7 @@ All notable changes to this project will be documented in this file.
3637
[#919]: https://github.com/stackabletech/operator-rs/pull/919
3738
[#920]: https://github.com/stackabletech/operator-rs/pull/920
3839
[#922]: https://github.com/stackabletech/operator-rs/pull/922
40+
[#923]: https://github.com/stackabletech/operator-rs/pull/923
3941
[#924]: https://github.com/stackabletech/operator-rs/pull/924
4042

4143
## [0.4.1] - 2024-10-23

0 commit comments

Comments
 (0)