Skip to content

Commit cb18b5f

Browse files
committed
MINOR: add validation cpu-set's directive in global section
Signed-off-by: Vincent Gramer <[email protected]>
1 parent 076967b commit cb18b5f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

handlers/global.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package handlers
1818
import (
1919
"github.com/go-openapi/runtime/middleware"
2020
client_native "github.com/haproxytech/client-native/v6"
21+
client_conf "github.com/haproxytech/client-native/v6/configuration"
2122
"github.com/haproxytech/client-native/v6/models"
2223
cn "github.com/haproxytech/dataplaneapi/client-native"
2324
"github.com/haproxytech/dataplaneapi/haproxy"
@@ -82,6 +83,13 @@ func (h *ReplaceGlobalHandlerImpl) Handle(params global.ReplaceGlobalParams, pri
8283
}
8384
return global.NewReplaceGlobalDefault(int(*e.Code)).WithPayload(e)
8485
}
86+
// validate constraints that can not be validated by the swagger 2.0 spec.
87+
if err := client_conf.ValidateGlobalSection(params.Data); err != nil {
88+
code := misc.ErrHTTPBadRequest
89+
msg := err.Error()
90+
e := &models.Error{Code: &code, Message: &msg}
91+
return global.NewReplaceGlobalDefault(int(misc.ErrHTTPBadRequest)).WithPayload(e)
92+
}
8593

8694
err := h.pushGlobalConfiguration(params, t, v)
8795
if err != nil {

0 commit comments

Comments
 (0)