Compare commits

..

1 Commits

Author SHA1 Message Date
f111787976 v1.6.10 2023-12-14 17:52:12 +03:00
23 changed files with 39 additions and 60 deletions

View File

@@ -1,4 +1,4 @@
## Version 1.6.13
## Version 1.6.10
### Bugfix
- Fix url for Disable method in cloudapi/bservice
## Bugfix
- Fix panic for nil pointer response reference in client and legacy-client

View File

@@ -159,7 +159,7 @@ func (dc *DecortClient) do(req *http.Request, ctype string) ([]byte, error) {
return nil, err
}
defer resp.Body.Close()
// handle successful request
respBytes, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 {
@@ -174,6 +174,7 @@ func (dc *DecortClient) do(req *http.Request, ctype string) ([]byte, error) {
func createK8sCloudApi(req k8s_ca.CreateRequest) (*bytes.Buffer, string) {
reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody)
defer writer.Close()
if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
@@ -280,14 +281,13 @@ func createK8sCloudApi(req k8s_ca.CreateRequest) (*bytes.Buffer, string) {
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
ct := writer.FormDataContentType()
writer.Close()
return reqBody, ct
}
func createK8sCloudBroker(req k8s_cb.CreateRequest) (*bytes.Buffer, string) {
reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody)
defer writer.Close()
if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
@@ -394,7 +394,5 @@ func createK8sCloudBroker(req k8s_cb.CreateRequest) (*bytes.Buffer, string) {
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
ct := writer.FormDataContentType()
writer.Close()
return reqBody, ct
}

View File

@@ -39,7 +39,7 @@ var (
sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"}
networkPluginValues = []string{"flannel", "weavenet", "calico"}
networkPluginValues = []string{"flannel", "weawenet", "calico"}
strictLooseValues = []string{"strict", "loose"}

View File

@@ -156,10 +156,11 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) ([]byte, erro
return nil, err
}
defer resp.Body.Close()
// handle successful request
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
if err!= nil {
return nil, err
}
if resp.StatusCode == 200 {
@@ -174,6 +175,7 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) ([]byte, erro
func createK8sCloudApiLegacy(req k8s_ca.CreateRequest, token string) (*bytes.Buffer, string) {
reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody)
defer writer.Close()
if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
@@ -282,14 +284,13 @@ func createK8sCloudApiLegacy(req k8s_ca.CreateRequest, token string) (*bytes.Buf
_ = writer.WriteField("authkey", token)
ct := writer.FormDataContentType()
writer.Close()
return reqBody, ct
}
func createK8sCloudBrokerLegacy(req k8s_cb.CreateRequest, token string) (*bytes.Buffer, string) {
reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody)
defer writer.Close()
if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
@@ -398,7 +399,5 @@ func createK8sCloudBrokerLegacy(req k8s_cb.CreateRequest, token string) (*bytes.
_ = writer.WriteField("authkey", token)
ct := writer.FormDataContentType()
writer.Close()
return reqBody, ct
}

View File

@@ -24,7 +24,7 @@ func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error)
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/bservice/disable"
url := "/cloudapi/bservice/delete"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {

View File

@@ -169,15 +169,6 @@ type ItemSnapshot struct {
}
// List of Snapshots
type ListInfoSnapshots struct {
// Data
Data ListSnapshots `json:"data"`
// EntryCount
EntryCount uint64 `json:"entryCount"`
}
// List of Snapshots inside RecordBasicService
type ListSnapshots []ItemSnapshot
// Main information about Group

View File

@@ -16,7 +16,7 @@ type SnapshotListRequest struct {
}
// SnapshotList gets list existing snapshots of the Basic Service
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, error) {
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -29,12 +29,12 @@ func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*L
return nil, err
}
list := ListInfoSnapshots{}
list := ListSnapshots{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
return list, nil
}

View File

@@ -38,8 +38,8 @@ type AffinityRuleAddRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AffinityRuleAdd add affinity rule

View File

@@ -38,8 +38,8 @@ type AffinityRuleRemoveRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AffinityRuleRemove remove affinity rule

View File

@@ -38,8 +38,8 @@ type AntiAffinityRuleAddRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AntiAffinityRuleAdd add anti affinity rule

View File

@@ -38,8 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AntiAffinityRuleRemove remove anti affinity rule

View File

@@ -29,7 +29,7 @@ type CreateRequest struct {
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
// Network plugin
// Must be one of these values: flannel, weavenet, calico
// Must be one of these values: flannel, weawenet, calico
// Required: true
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`

View File

@@ -331,18 +331,9 @@ type ItemAffinityGroupComputes struct {
// List of affinity groups
type ListAffinityGroupsComputes []ItemAffinityGroupComputes
// Main information about
type ItemAffinityGroup struct {
ID uint64 `json:"id"`
NodeID uint64 `json:"node_id"`
}
// List of affinity group
type ListAffinityGroup []ItemAffinityGroup
type ListAffinityGroups struct {
// Data
Data []map[string]ListAffinityGroup `json:"data"`
Data []map[string][]uint64 `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`

View File

@@ -40,8 +40,8 @@ type AffinityRuleAddRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AffinityRuleAdd adds affinity rule

View File

@@ -38,8 +38,8 @@ type AffinityRuleRemoveRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AffinityRuleRemove remove affinity rule

View File

@@ -38,8 +38,8 @@ type AntiAffinityRuleAddRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AntiAffinityRuleAdd adds anti affinity rule

View File

@@ -38,8 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule
// Required: false
Value string `url:"value" json:"value"`
// Required: true
Value string `url:"value" json:"value" validate:"required"`
}
// AntiAffinityRuleRemove removes anti affinity rule

View File

@@ -43,4 +43,4 @@ func (lpd ListPCIDevices) IDs() []uint64 {
res = append(res, pd.ID)
}
return res
}
}

View File

@@ -721,7 +721,7 @@ type RecordCompute struct {
}
// Information about of disk IDs
type ListInfoDisks []InfoDisk
type ListInfoDisks []InfoDisk
// Main information about compute for list
type ItemCompute struct {

View File

@@ -60,7 +60,7 @@ type CreateRequest struct {
MaxWorkerCount uint64 `url:"maxWorkerCount" json:"maxWorkerCount" validate:"required"`
// Network plugins
// Values of slice must be flannel, weavenet or calico
// Values of slice must be flannel, weawenet or calico
//Required: true
NetworkPlugins []string `url:"networkPlugins" json:"networkPlugins" validate:"required,networkPlugins"`
}

View File

@@ -16,7 +16,7 @@ type DeleteRequest struct {
// Delete permanently or not
// Required: false
Permanently bool `url:"permanently" json:"permanently"`
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
}
// Delete deletes K8CI by ID

View File

@@ -29,7 +29,7 @@ type CreateRequest struct {
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
// Network plugin
// Must be one of these values: flannel, weavenet, calico
// Must be one of these values: flunnel, weawenet, calico
// Required: true
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`

View File

@@ -17,7 +17,7 @@ type DeleteRequest struct {
// True if cluster is destroyed permanently.
// Otherwise it can be restored from recycle bin
// Required: false
Permanently bool `url:"permanently" json:"permanently"`
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
}
// Delete deletes kubernetes cluster