27
27
28
28
use std:: collections:: BTreeMap ;
29
29
30
- use derivative:: Derivative ;
31
30
use kube:: CustomResource ;
32
31
use schemars:: JsonSchema ;
33
32
use serde:: { Deserialize , Serialize } ;
@@ -56,6 +55,20 @@ pub struct ListenerClassSpec {
56
55
/// Annotations that should be added to the Service object.
57
56
#[ serde( default ) ]
58
57
pub service_annotations : BTreeMap < String , String > ,
58
+
59
+ /// `externalTrafficPolicy` that should be set on the created [`Service`] objects.
60
+ ///
61
+ /// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload
62
+ /// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that
63
+ /// break Local mode (IONOS so far).
64
+ #[ serde( default = "ListenerClassSpec::default_service_external_traffic_policy" ) ]
65
+ pub service_external_traffic_policy : KubernetesTrafficPolicy ,
66
+ }
67
+
68
+ impl ListenerClassSpec {
69
+ const fn default_service_external_traffic_policy ( ) -> KubernetesTrafficPolicy {
70
+ KubernetesTrafficPolicy :: Local
71
+ }
59
72
}
60
73
61
74
/// The method used to access the services.
@@ -100,9 +113,8 @@ pub enum KubernetesTrafficPolicy {
100
113
///
101
114
/// Learn more in the [Listener documentation](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listener).
102
115
#[ derive(
103
- CustomResource , Serialize , Deserialize , Clone , Debug , JsonSchema , PartialEq , Eq , Derivative ,
116
+ CustomResource , Serialize , Deserialize , Default , Clone , Debug , JsonSchema , PartialEq , Eq ,
104
117
) ]
105
- #[ derivative( Default ) ]
106
118
#[ kube(
107
119
group = "listeners.stackable.tech" ,
108
120
version = "v1alpha1" ,
@@ -125,25 +137,12 @@ pub struct ListenerSpec {
125
137
/// Whether incoming traffic should also be directed to Pods that are not `Ready`.
126
138
#[ serde( default = "ListenerSpec::default_publish_not_ready_addresses" ) ]
127
139
pub publish_not_ready_addresses : Option < bool > ,
128
-
129
- /// `externalTrafficPolicy` that should be set on the [`Service`] object.
130
- ///
131
- /// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload
132
- /// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that
133
- /// break Local mode (IONOS so far).
134
- #[ derivative( Default ( value = "ListenerSpec::default_service_external_traffic_policy()" ) ) ]
135
- #[ serde( default = "ListenerSpec::default_service_external_traffic_policy" ) ]
136
- pub service_external_traffic_policy : KubernetesTrafficPolicy ,
137
140
}
138
141
139
142
impl ListenerSpec {
140
143
const fn default_publish_not_ready_addresses ( ) -> Option < bool > {
141
144
Some ( true )
142
145
}
143
-
144
- const fn default_service_external_traffic_policy ( ) -> KubernetesTrafficPolicy {
145
- KubernetesTrafficPolicy :: Local
146
- }
147
146
}
148
147
149
148
#[ derive( Serialize , Deserialize , Clone , Debug , JsonSchema , PartialEq , Eq ) ]
0 commit comments