You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
package k8s
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// WorkerAddRequest struct to add worker to a kubernetes cluster
|
|
type WorkerAddRequest struct {
|
|
// Kubernetes cluster ID
|
|
// Required: true
|
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
|
|
|
// ID of the workers compute group
|
|
// Required: true
|
|
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
|
|
|
// How many worker nodes to add
|
|
// Required: false
|
|
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
|
|
}
|
|
|
|
// WorkerAdd adds worker nodes to a Kubernetes cluster
|
|
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) ([]uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/k8s/workerAdd"
|
|
|
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
result := make([]uint64, 0)
|
|
|
|
err = json.Unmarshal(res, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|