11use std:: ops:: Not ;
22
3- use darling:: { util:: IdentString , Error , FromAttributes , Result } ;
3+ use darling:: { util:: IdentString , Error , FromAttributes , FromMeta , Result } ;
44use proc_macro2:: TokenStream ;
55use quote:: { quote, ToTokens } ;
66use syn:: { parse_quote, ItemStruct , Path } ;
@@ -342,6 +342,19 @@ impl Struct {
342342 // module (in standalone mode).
343343 let automatically_derived = is_nested. not ( ) . then ( || quote ! { #[ automatically_derived] } ) ;
344344
345+ let k8s_openapi_crate_default = & Path :: from_string ( "::k8s_openapi" ) . expect ( "valid path" ) ;
346+ let k8s_openapi_crate = self . common . options . kubernetes_options . as_ref ( ) . map_or_else (
347+ || quote ! { #k8s_openapi_crate_default} ,
348+ |options| {
349+ if let Some ( crates) = & options. crates {
350+ if let Some ( k8s_openapi) = & crates. k8s_openapi {
351+ return quote ! { #k8s_openapi} ;
352+ }
353+ }
354+ quote ! { #k8s_openapi_crate_default}
355+ } ,
356+ ) ;
357+
345358 // TODO (@Techassi): Use proper visibility instead of hard-coding 'pub'
346359 // TODO (@Techassi): Move the YAML printing code into 'stackable-versioned' so that we don't
347360 // have any cross-dependencies and the macro can be used on it's own (K8s features of course
@@ -366,7 +379,7 @@ impl Struct {
366379 /// Generates a merged CRD which contains all versions defined using the `#[versioned()]` macro.
367380 pub fn merged_crd(
368381 stored_apiversion: Self
369- ) -> :: std:: result:: Result <:: k8s_openapi :: apiextensions_apiserver:: pkg:: apis:: apiextensions:: v1:: CustomResourceDefinition , :: kube:: core:: crd:: MergeError > {
382+ ) -> :: std:: result:: Result <#k8s_openapi_crate :: apiextensions_apiserver:: pkg:: apis:: apiextensions:: v1:: CustomResourceDefinition , :: kube:: core:: crd:: MergeError > {
370383 :: kube:: core:: crd:: merge_crds( vec![ #( #fn_calls) , * ] , & stored_apiversion. to_string( ) )
371384 }
372385
0 commit comments