This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,21 +7,28 @@ import (
"strconv"
)
// Request struct for add worker to a kubernetes cluster
type WorkerAddRequest struct {
K8SID uint64 `url:"k8sId"`
// Kubernetes cluster ID
// Required: true
K8SID uint64 `url:"k8sId"`
// ID of the workers compute group
// Required: true
WorkersGroupID uint64 `url:"workersGroupId"`
Num uint `url:"num"`
// How many worker nodes to add
// Required: true
Num uint64 `url:"num"`
}
func (krq WorkerAddRequest) Validate() error {
func (krq WorkerAddRequest) validate() error {
if krq.K8SID == 0 {
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
}
if krq.WorkersGroupID == 0 {
return errors.New("validation-error: field WorkersGroupID can not be empty or equal to 0")
}
if krq.Num == 0 {
return errors.New("validation-error: field Num can not be empty or equal to 0")
}
@@ -29,8 +36,9 @@ func (krq WorkerAddRequest) Validate() error {
return nil
}
// WorkerAdd add worker nodes to a Kubernetes cluster
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) (bool, error) {
err := req.Validate()
err := req.validate()
if err != nil {
return false, err
}
@@ -46,5 +54,6 @@ func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) (bool, error
if err != nil {
return false, err
}
return result, nil
}