v1.0.0
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user