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.
decort-golang-sdk/pkg/cloudapi/k8s/worker_add.go

51 lines
1.2 KiB

package k8s
import (
"context"
3 years ago
"encoding/json"
"net/http"
2 years ago
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
3 years ago
// Request struct for add worker to a kubernetes cluster
type WorkerAddRequest struct {
3 years ago
// Kubernetes cluster ID
// Required: true
3 years ago
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
3 years ago
// ID of the workers compute group
// Required: true
3 years ago
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
3 years ago
// How many worker nodes to add
2 years ago
// Required: false
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
}
3 years ago
// WorkerAdd add worker nodes to a Kubernetes cluster
3 years ago
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) ([]uint64, error) {
3 years ago
err := validators.ValidateRequest(req)
if err != nil {
3 years ago
for _, validationError := range validators.GetErrors(err) {
3 years ago
return nil, validators.ValidationError(validationError)
3 years ago
}
}
url := "/cloudapi/k8s/workerAdd"
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
3 years ago
return nil, err
}
3 years ago
result := make([]uint64, 0)
err = json.Unmarshal(res, &result)
if err != nil {
3 years ago
return nil, err
}
3 years ago
return result, nil
}