@@ -18,93 +18,105 @@ use std::collections::BTreeMap;
1818use thiserror:: Error ;
1919use typed_builder:: TypedBuilder ;
2020
21+ /// Default Kubernetes version for clusters
22+ pub const DEFAULT_KUBE_TAG : & str = "v1.30.0" ;
23+
2124#[ derive( Clone , Default , Deserialize , FromPyObject ) ]
2225pub struct ClusterTemplate {
2326 pub network_driver : String ,
2427}
2528
26- #[ derive( Clone , Default , Deserialize , FromPyObject , TypedBuilder ) ]
29+ #[ derive( Clone , Default , Deserialize , TypedBuilder ) ]
2730#[ pyo3( from_item_all) ]
2831pub struct ClusterLabels {
2932 /// The tag of the Cilium container image to use for the cluster.
3033 #[ builder( default ="v1.15.3" . to_owned( ) ) ]
31- #[ pyo3( default ="v1.15.3" . to_owned( ) ) ]
3234 pub cilium_tag : String ,
3335
3436 /// The IP address range to use for the Cilium IPAM pool.
3537 #[ builder( default ="10.100.0.0/16" . to_owned( ) ) ]
36- #[ pyo3( default ="10.100.0.0/16" . to_owned( ) ) ]
3738 pub cilium_ipv4pool : String ,
3839
3940 /// Enable the use of the Cinder CSI driver for the cluster.
4041 #[ builder( default = true ) ]
41- #[ pyo3( default = true ) ]
4242 pub cinder_csi_enabled : bool ,
4343
4444 /// The tag of the Cinder CSI container image to use for the cluster.
4545 #[ builder( default ="v1.32.0" . to_owned( ) ) ]
46- #[ pyo3( default ="v1.32.0" . to_owned( ) ) ]
4746 pub cinder_csi_plugin_tag : String ,
4847
4948 /// Enable the use of the Manila CSI driver for the cluster.
5049 #[ builder( default = true ) ]
51- #[ pyo3( default = true ) ]
5250 pub manila_csi_enabled : bool ,
5351
5452 /// The tag of the Manila CSI container image to use for the cluster.
5553 #[ builder( default ="v1.32.0" . to_owned( ) ) ]
56- #[ pyo3( default ="v1.32.0" . to_owned( ) ) ]
5754 pub manila_csi_plugin_tag : String ,
5855
5956 /// The tag to use for the OpenStack cloud controller provider
6057 /// when bootstrapping the cluster. If not specified, it will be
6158 /// automatically selected based on the Kubernetes version.
6259 #[ builder( default ) ]
63- #[ pyo3( default ) ]
6460 pub cloud_provider_tag : Option < String > ,
6561
6662 /// The prefix of the container images to use for the cluster, which
6763 /// defaults to the upstream images if not set.
6864 #[ builder( default ) ]
69- #[ pyo3( default ) ]
7065 pub container_infra_prefix : Option < String > ,
7166
7267 /// CSI attacher tag to use for the cluster.
7368 #[ builder( default ="v4.7.0" . to_owned( ) ) ]
74- #[ pyo3( default ="v4.7.0" . to_owned( ) ) ]
7569 pub csi_attacher_tag : String ,
7670
7771 /// CSI liveness probe tag to use for the cluster.
7872 #[ builder( default ="v2.14.0" . to_owned( ) ) ]
79- #[ pyo3( default ="v2.14.0" . to_owned( ) ) ]
8073 pub csi_liveness_probe_tag : String ,
8174
8275 /// CSI Node Driver Registrar tag to use for the cluster.
8376 #[ builder( default ="v2.12.0" . to_owned( ) ) ]
84- #[ pyo3( default ="v2.12.0" . to_owned( ) ) ]
8577 pub csi_node_driver_registrar_tag : String ,
8678
8779 // CSI Provisioner tag to use for the cluster.
8880 #[ builder( default ="v5.1.0" . to_owned( ) ) ]
89- #[ pyo3( default ="v5.1.0" . to_owned( ) ) ]
9081 pub csi_provisioner_tag : String ,
9182
9283 /// CSI Resizer tag to use for the cluster.
9384 #[ builder( default ="v1.12.0" . to_owned( ) ) ]
94- #[ pyo3( default ="v1.12.0" . to_owned( ) ) ]
9585 pub csi_resizer_tag : String ,
9686
9787 /// CSI Snapshotter tag to use for the cluster.
9888 #[ builder( default ="v8.1.0" . to_owned( ) ) ]
99- #[ pyo3( default ="v8.1.0" . to_owned( ) ) ]
10089 pub csi_snapshotter_tag : String ,
10190
10291 /// The Kubernetes version to use for the cluster.
103- #[ builder( default ="v1.30.0" . to_owned( ) ) ]
104- #[ pyo3( default ="v1.30.0" . to_owned( ) ) ]
92+ #[ builder( default =DEFAULT_KUBE_TAG . to_owned( ) ) ]
10593 pub kube_tag : String ,
10694}
10795
96+ impl < ' py > FromPyObject < ' py > for ClusterLabels {
97+ fn extract_bound ( ob : & Bound < ' py , PyAny > ) -> PyResult < Self > {
98+ let mut labels = ClusterLabels :: default ( ) ;
99+
100+ if let Ok ( val) = ob. get_item ( "cilium_tag" ) { labels. cilium_tag = val. extract ( ) ?; }
101+ if let Ok ( val) = ob. get_item ( "cilium_ipv4pool" ) { labels. cilium_ipv4pool = val. extract ( ) ?; }
102+ if let Ok ( val) = ob. get_item ( "cinder_csi_enabled" ) { labels. cinder_csi_enabled = val. extract ( ) ?; }
103+ if let Ok ( val) = ob. get_item ( "cinder_csi_plugin_tag" ) { labels. cinder_csi_plugin_tag = val. extract ( ) ?; }
104+ if let Ok ( val) = ob. get_item ( "manila_csi_enabled" ) { labels. manila_csi_enabled = val. extract ( ) ?; }
105+ if let Ok ( val) = ob. get_item ( "manila_csi_plugin_tag" ) { labels. manila_csi_plugin_tag = val. extract ( ) ?; }
106+ if let Ok ( val) = ob. get_item ( "cloud_provider_tag" ) { labels. cloud_provider_tag = val. extract ( ) ?; }
107+ if let Ok ( val) = ob. get_item ( "container_infra_prefix" ) { labels. container_infra_prefix = val. extract ( ) ?; }
108+ if let Ok ( val) = ob. get_item ( "csi_attacher_tag" ) { labels. csi_attacher_tag = val. extract ( ) ?; }
109+ if let Ok ( val) = ob. get_item ( "csi_liveness_probe_tag" ) { labels. csi_liveness_probe_tag = val. extract ( ) ?; }
110+ if let Ok ( val) = ob. get_item ( "csi_node_driver_registrar_tag" ) { labels. csi_node_driver_registrar_tag = val. extract ( ) ?; }
111+ if let Ok ( val) = ob. get_item ( "csi_provisioner_tag" ) { labels. csi_provisioner_tag = val. extract ( ) ?; }
112+ if let Ok ( val) = ob. get_item ( "csi_resizer_tag" ) { labels. csi_resizer_tag = val. extract ( ) ?; }
113+ if let Ok ( val) = ob. get_item ( "csi_snapshotter_tag" ) { labels. csi_snapshotter_tag = val. extract ( ) ?; }
114+ if let Ok ( val) = ob. get_item ( "kube_tag" ) { labels. kube_tag = val. extract ( ) ?; }
115+
116+ Ok ( labels)
117+ }
118+ }
119+
108120impl ClusterLabels {
109121 const DEFAULT_CLOUD_PROVIDER_TAG : & ' static str = "v1.34.1" ;
110122
0 commit comments