@@ -23,6 +23,7 @@ import (
23
23
client_native "github.com/haproxytech/client-native/v6"
24
24
native_errors "github.com/haproxytech/client-native/v6/errors"
25
25
"github.com/haproxytech/client-native/v6/models"
26
+ cn_runtime "github.com/haproxytech/client-native/v6/runtime"
26
27
27
28
"github.com/haproxytech/dataplaneapi/misc"
28
29
"github.com/haproxytech/dataplaneapi/operations/server"
@@ -168,7 +169,13 @@ func (h *AddRuntimeServerHandlerImpl) Handle(params server.AddRuntimeServerParam
168
169
return server .NewAddRuntimeServerBadRequest ().WithPayload (& models.Error {Code : & code , Message : & msg })
169
170
}
170
171
171
- err = runtime .AddServer (params .ParentName , params .Data .Name , SerializeRuntimeAddServer (params .Data ))
172
+ haversion , err := runtime .GetVersion ()
173
+ if err != nil {
174
+ e := misc .HandleError (err )
175
+ return server .NewAddRuntimeServerDefault (int (* e .Code )).WithPayload (e )
176
+ }
177
+
178
+ err = runtime .AddServer (params .ParentName , params .Data .Name , SerializeRuntimeAddServer (params .Data , & haversion ))
172
179
if err != nil {
173
180
msg := err .Error ()
174
181
switch {
@@ -236,7 +243,7 @@ func (h *DeleteRuntimeServerHandlerImpl) Handle(params server.DeleteRuntimeServe
236
243
// SerializeRuntimeAddServer returns a string in the HAProxy config format, suitable
237
244
// for the "add server" operation over the control socket.
238
245
// Not all the Server attributes are available in this case.
239
- func SerializeRuntimeAddServer (srv * models.RuntimeAddServer ) string { //nolint:cyclop,maintidx
246
+ func SerializeRuntimeAddServer (srv * models.RuntimeAddServer , version * cn_runtime. HAProxyVersion ) string { //nolint:cyclop,maintidx
240
247
b := & strings.Builder {}
241
248
242
249
push := func (s string ) {
@@ -311,7 +318,11 @@ func SerializeRuntimeAddServer(srv *models.RuntimeAddServer) string { //nolint:c
311
318
case srv .Downinter != nil :
312
319
pushi ("downinter" , srv .Downinter )
313
320
case ! enabled (srv .Maintenance ):
314
- push ("enabled" )
321
+ required := new (cn_runtime.HAProxyVersion )
322
+ required .ParseHAProxyVersion ("3.0.0" )
323
+ if ! cn_runtime .IsBiggerOrEqual (required , version ) {
324
+ push ("enabled" )
325
+ }
315
326
case srv .ErrorLimit != nil :
316
327
pushi ("error-limit" , srv .ErrorLimit )
317
328
case srv .Fall != nil :
0 commit comments