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/cloudbroker/k8s/worker_add.go

53 lines
1.3 KiB

3 years ago
package k8s
import (
"context"
"encoding/json"
"net/http"
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
3 years ago
)
2 years ago
// WorkerAddRequest struct to add worker to a kubernetes cluster
3 years ago
type WorkerAddRequest struct {
// 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
3 years ago
// Required: false
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
1 year ago
// Type of the emulated system, Q35 or i440fx
// Required: false
1 year ago
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
3 years ago
}
// WorkerAdd adds worker nodes to a kubernetes cluster
func (k K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) ([]uint64, error) {
3 years ago
err := validators.ValidateRequest(req)
3 years ago
if err != nil {
2 years ago
return nil, validators.ValidationErrors(validators.GetErrors(err))
3 years ago
}
url := "/cloudbroker/k8s/workerAdd"
res, err := k.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
}