1- use serde:: { Deserialize , Serialize } ;
21use stackable_operator:: {
32 cli:: OperatorEnvironmentOptions ,
4- kube:: { Client , CustomResource } ,
5- schemars:: { self , JsonSchema } ,
6- versioned:: versioned,
3+ kube:: Client ,
74 webhook:: {
85 constants:: CONVERSION_WEBHOOK_HTTPS_PORT ,
96 servers:: { ConversionWebhookOptions , ConversionWebhookServer } ,
@@ -28,10 +25,6 @@ pub async fn conversion_webhook(
2825 TrustStore :: merged_crd ( TrustStoreVersion :: V1Alpha1 ) ?,
2926 TrustStore :: try_convert as fn ( _) -> _ ,
3027 ) ,
31- (
32- Person :: merged_crd ( PersonVersion :: V1Alpha1 ) ?,
33- Person :: try_convert as fn ( _) -> _ ,
34- ) ,
3528 ] ;
3629
3730 let options = ConversionWebhookOptions {
@@ -45,92 +38,3 @@ pub async fn conversion_webhook(
4538
4639 Ok ( ConversionWebhookServer :: new ( crds_and_handlers, options, client) . await ?)
4740}
48-
49- // !!! TESTING struct!!!
50- // !!! Will be removed later!!!
51- #[ versioned(
52- version( name = "v1alpha1" ) ,
53- version( name = "v1alpha2" ) ,
54- version( name = "v1beta1" ) ,
55- version( name = "v2" ) ,
56- version( name = "v3" ) ,
57- options( k8s( experimental_conversion_tracking) ) ,
58- crates(
59- kube_core = "stackable_operator::kube::core" ,
60- kube_client = "stackable_operator::kube::client" ,
61- k8s_openapi = "stackable_operator::k8s_openapi" ,
62- schemars = "stackable_operator::schemars" ,
63- versioned = "stackable_operator::versioned" ,
64- )
65- ) ]
66- pub mod versioned {
67- #[ versioned( crd( group = "test.stackable.tech" , status = "PersonStatus" , ) ) ]
68- #[ derive( Clone , Debug , CustomResource , Deserialize , JsonSchema , Serialize ) ]
69- #[ serde( rename_all = "camelCase" ) ]
70- pub struct PersonSpec {
71- username : String ,
72-
73- // In v1alpha2 first and last name have been added
74- #[ versioned( added( since = "v1alpha2" ) ) ]
75- first_name : String ,
76-
77- #[ versioned( added( since = "v1alpha2" ) ) ]
78- last_name : String ,
79-
80- // We started out with a enum. As we *need* to provide a default, we have a Unknown variant.
81- // Afterwards we figured let's be more flexible and accept any arbitrary String.
82- #[ versioned( added( since = "v2" ) , changed( since = "v3" , from_type = "Gender" ) ) ]
83- gender : String ,
84-
85- #[ versioned( nested) ]
86- socials : Socials ,
87- }
88-
89- #[ derive( Clone , Debug , Deserialize , Serialize , JsonSchema ) ]
90- pub struct Socials {
91- email : String ,
92-
93- #[ versioned( added( since = "v1beta1" ) ) ]
94- mastodon : String ,
95- }
96- }
97-
98- #[ derive( Clone , Debug , Deserialize , Serialize , JsonSchema ) ]
99- pub struct PersonStatus {
100- pub alive : bool ,
101- }
102-
103- impl Default for PersonStatus {
104- fn default ( ) -> Self {
105- Self { alive : true }
106- }
107- }
108-
109- #[ derive( Clone , Debug , Default , Deserialize , Serialize , JsonSchema ) ]
110- #[ serde( rename_all = "PascalCase" ) ]
111- pub enum Gender {
112- #[ default]
113- Unknown ,
114- Male ,
115- Female ,
116- }
117-
118- impl From < Gender > for String {
119- fn from ( value : Gender ) -> Self {
120- match value {
121- Gender :: Unknown => "Unknown" . to_owned ( ) ,
122- Gender :: Male => "Male" . to_owned ( ) ,
123- Gender :: Female => "Female" . to_owned ( ) ,
124- }
125- }
126- }
127-
128- impl From < String > for Gender {
129- fn from ( value : String ) -> Self {
130- match value. as_str ( ) {
131- "Male" => Self :: Male ,
132- "Female" => Self :: Female ,
133- _ => Self :: Unknown ,
134- }
135- }
136- }
0 commit comments