File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ pub mod v1 {
12
12
///
13
13
/// This is using the stable v1::CustomResourceDefinitions (present in kubernetes >= 1.16)
14
14
fn crd ( ) -> super :: apiexts:: v1:: CustomResourceDefinition ;
15
+ /// Helper to return the name of this `CustomResourceDefinition` in kubernetes.
16
+ ///
17
+ /// This is not the name of an _instance_ of this custom resource but the `CustomResourceDefinition` object itself.
18
+ fn crd_name ( ) -> & ' static str ;
15
19
/// Helper to generate the api information type for use with the dynamic `Api`
16
20
fn api_resource ( ) -> crate :: discovery:: ApiResource ;
17
21
}
@@ -27,6 +31,10 @@ pub mod v1beta1 {
27
31
///
28
32
/// This is using v1beta1::CustomResourceDefinitions (which will be removed in kubernetes 1.22)
29
33
fn crd ( ) -> super :: apiexts:: v1beta1:: CustomResourceDefinition ;
34
+ /// Helper to return the name of this `CustomResourceDefinition` in kubernetes.
35
+ ///
36
+ /// This is not the name of an _instance_ of this custom resource but the `CustomResourceDefinition` object itself.
37
+ fn crd_name ( ) -> & ' static str ;
30
38
/// Helper to generate the api information type for use with the dynamic `Api`
31
39
fn api_resource ( ) -> crate :: discovery:: ApiResource ;
32
40
}
Original file line number Diff line number Diff line change @@ -368,6 +368,10 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea
368
368
. expect( "valid custom resource from #[kube(attrs..)]" )
369
369
}
370
370
371
+ fn crd_name( ) -> & ' static str {
372
+ #crd_meta_name
373
+ }
374
+
371
375
fn api_resource( ) -> kube:: core:: ApiResource {
372
376
kube:: core:: ApiResource :: erase:: <Self >( & ( ) )
373
377
}
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ fn default_nullable() -> Option<String> {
43
43
Some ( "default_nullable" . into ( ) )
44
44
}
45
45
46
+ #[ test]
47
+ fn test_crd_name ( ) {
48
+ use kube:: core:: CustomResourceExt ;
49
+ assert_eq ! ( "foos.clux.dev" , Foo :: crd_name( ) ) ;
50
+ }
51
+
46
52
#[ test]
47
53
fn test_crd_schema_matches_expected ( ) {
48
54
use kube:: core:: CustomResourceExt ;
You can’t perform that action at this time.
0 commit comments