@@ -26,16 +26,18 @@ import (
26
26
type ParserOption [ComponentConfigType any ] func (* Settings [ComponentConfigType ])
27
27
28
28
type Settings [ComponentConfigType any ] struct {
29
- protocol corev1.Protocol
30
- appProtocol * string
31
- targetPort intstr.IntOrString
32
- nodePort int32
33
- name string
34
- port int32
35
- portParser PortParser [ComponentConfigType ]
36
- rbacGen RBACRuleGenerator [ComponentConfigType ]
37
- livenessGen ProbeGenerator [ComponentConfigType ]
38
- readinessGen ProbeGenerator [ComponentConfigType ]
29
+ protocol corev1.Protocol
30
+ appProtocol * string
31
+ targetPort intstr.IntOrString
32
+ nodePort int32
33
+ name string
34
+ port int32
35
+ defaultRecAddr string
36
+ portParser PortParser [ComponentConfigType ]
37
+ rbacGen RBACRuleGenerator [ComponentConfigType ]
38
+ livenessGen ProbeGenerator [ComponentConfigType ]
39
+ readinessGen ProbeGenerator [ComponentConfigType ]
40
+ defaultsApplier Defaulter [ComponentConfigType ]
39
41
}
40
42
41
43
func NewEmptySettings [ComponentConfigType any ]() * Settings [ComponentConfigType ] {
@@ -75,6 +77,11 @@ func (b Builder[ComponentConfigType]) WithAppProtocol(appProtocol *string) Build
75
77
o .appProtocol = appProtocol
76
78
})
77
79
}
80
+ func (b Builder [ComponentConfigType ]) WithDefaultRecAddress (defaultRecAddr string ) Builder [ComponentConfigType ] {
81
+ return append (b , func (o * Settings [ComponentConfigType ]) {
82
+ o .defaultRecAddr = defaultRecAddr
83
+ })
84
+ }
78
85
func (b Builder [ComponentConfigType ]) WithTargetPort (targetPort int32 ) Builder [ComponentConfigType ] {
79
86
return append (b , func (o * Settings [ComponentConfigType ]) {
80
87
o .targetPort = intstr .FromInt32 (targetPort )
@@ -118,19 +125,26 @@ func (b Builder[ComponentConfigType]) WithReadinessGen(readinessGen ProbeGenerat
118
125
})
119
126
}
120
127
128
+ func (b Builder [ComponentConfigType ]) WithDefaultsApplier (defaultsApplier Defaulter [ComponentConfigType ]) Builder [ComponentConfigType ] {
129
+ return append (b , func (o * Settings [ComponentConfigType ]) {
130
+ o .defaultsApplier = defaultsApplier
131
+ })
132
+ }
133
+
121
134
func (b Builder [ComponentConfigType ]) Build () (* GenericParser [ComponentConfigType ], error ) {
122
135
o := NewEmptySettings [ComponentConfigType ]()
123
136
o .Apply (b ... )
124
137
if len (o .name ) == 0 {
125
138
return nil , fmt .Errorf ("invalid settings struct, no name specified" )
126
139
}
127
140
return & GenericParser [ComponentConfigType ]{
128
- name : o .name ,
129
- portParser : o .portParser ,
130
- rbacGen : o .rbacGen ,
131
- livenessGen : o .livenessGen ,
132
- readinessGen : o .readinessGen ,
133
- settings : o ,
141
+ name : o .name ,
142
+ portParser : o .portParser ,
143
+ rbacGen : o .rbacGen ,
144
+ livenessGen : o .livenessGen ,
145
+ readinessGen : o .readinessGen ,
146
+ defaultsApplier : o .defaultsApplier ,
147
+ settings : o ,
134
148
}, nil
135
149
}
136
150
0 commit comments