Compare commits

...

10 Commits

Author SHA1 Message Date
55027a1605 v1.6.13 2024-03-14 10:17:08 +03:00
de9cca4053 v1.7.6 2024-03-06 17:02:50 +03:00
83bf1fb1fa v1.6.12 2024-03-06 16:50:27 +03:00
16cad7a3e7 v1.7.5 2024-02-01 10:50:38 +03:00
96273d2a12 v1.7.4 2024-01-22 13:10:00 +03:00
d4065938ac v1.7.3 2023-12-18 16:27:15 +03:00
cd741b7f11 v1.7.2 2023-11-29 15:57:26 +03:00
a85ad3acd5 v1.7.1 2023-11-15 12:03:31 +03:00
823dfb49bc v1.7.0 2023-11-09 10:27:14 +03:00
e6440bc4a3 v1.6.9 2023-11-07 15:54:13 +03:00
23 changed files with 105 additions and 108 deletions

View File

@@ -1,7 +1,4 @@
## Version 1.6.8 ## Version 1.6.13
## Feature ### Bugfix
- Add IDs() methods returning array of uint64 IDs for all List* structs in cloudapi/cloudbroker groups - Fix url for Disable method in cloudapi/bservice
## Bugfix
- Fix field Audit in CloudBrokerEndpoints model in cloudbroker/apiaccess

View File

@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"context" "context"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"io" "io"
"mime/multipart" "mime/multipart"
@@ -97,22 +96,11 @@ func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, p
return nil, err return nil, err
} }
resp, err := dc.do(req, ctype) // perform request
if err != nil { var respBytes []byte
return nil, err respBytes, err = dc.do(req, ctype)
}
defer resp.Body.Close()
respBytes, err := io.ReadAll(resp.Body) return respBytes, err
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, errors.New(string(respBytes))
}
return respBytes, nil
} }
func (dc *DecortClient) getToken(ctx context.Context) error { func (dc *DecortClient) getToken(ctx context.Context) error {
@@ -149,7 +137,7 @@ func (dc *DecortClient) getToken(ctx context.Context) error {
return nil return nil
} }
func (dc *DecortClient) do(req *http.Request, ctype string) (*http.Response, error) { func (dc *DecortClient) do(req *http.Request, ctype string) ([]byte, error) {
if ctype != "" { if ctype != "" {
req.Header.Add("Content-Type", ctype) req.Header.Add("Content-Type", ctype)
} else { } else {
@@ -159,25 +147,27 @@ func (dc *DecortClient) do(req *http.Request, ctype string) (*http.Response, err
req.Header.Add("Authorization", "bearer "+dc.cfg.Token) req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
// var resp *http.Response buf, err := io.ReadAll(req.Body)
// var err error if err != nil {
buf, _ := io.ReadAll(req.Body) return nil, err
// req = req.Clone(req.Context())
// for i := uint64(0); i < dc.cfg.Retries; i++ {
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req)
// if err == nil {
if resp.StatusCode == 200 {
return resp, err
} }
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
// }
// }
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req)
if err != nil || resp == nil {
return nil, err
}
defer resp.Body.Close()
// handle successful request
respBytes, _ := io.ReadAll(resp.Body)
if resp.StatusCode == 200 {
return respBytes, nil
}
// handle errors with status code other than 200
err = fmt.Errorf("%s", respBytes)
return nil, fmt.Errorf("could not execute request: %w", err) return nil, fmt.Errorf("could not execute request: %w", err)
} }
@@ -402,7 +392,7 @@ func createK8sCloudBroker(req k8s_cb.CreateRequest) (*bytes.Buffer, string) {
} }
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly)) _ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
ct := writer.FormDataContentType() ct := writer.FormDataContentType()
writer.Close() writer.Close()

View File

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

View File

@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"context" "context"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"io" "io"
"mime/multipart" "mime/multipart"
@@ -78,7 +77,7 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest) k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest) k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
var body *bytes.Buffer var body *bytes.Buffer
var ctype string var ctype string
@@ -93,28 +92,17 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
} }
body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token)) body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
} }
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, body) req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
resp, err := ldc.do(req, ctype) // perform request
if err != nil { var respBytes []byte
return nil, err respBytes, err = ldc.do(req, ctype)
}
defer resp.Body.Close()
respBytes, err := io.ReadAll(resp.Body) return respBytes, err
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, errors.New(string(respBytes))
}
return respBytes, nil
} }
func (ldc *LegacyDecortClient) getToken(ctx context.Context) error { func (ldc *LegacyDecortClient) getToken(ctx context.Context) error {
@@ -148,7 +136,7 @@ func (ldc *LegacyDecortClient) getToken(ctx context.Context) error {
return nil return nil
} }
func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) (*http.Response, error) { func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) ([]byte, error) {
if ctype != "" { if ctype != "" {
req.Header.Add("Content-Type", ctype) req.Header.Add("Content-Type", ctype)
} else { } else {
@@ -156,26 +144,30 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) (*http.Respon
} }
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
// var resp *http.Response buf, err := io.ReadAll(req.Body)
// var err error if err != nil {
buf, _ := io.ReadAll(req.Body) return nil, err
// req = req.Clone(req.Context())
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := ldc.client.Do(req)
// if err == nil {
if resp.StatusCode == 200 {
return resp, err
} }
respBytes, _ := io.ReadAll(resp.Body) req.Body.Close()
err = fmt.Errorf("%s", respBytes) req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp.Body.Close()
// }
// }
resp, err := ldc.client.Do(req)
if err != nil || resp == nil {
return nil, err
}
defer resp.Body.Close()
// handle successful request
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode == 200 {
return respBytes, nil
}
// handle errors with status code other than 200
err = fmt.Errorf("%s", respBytes)
return nil, fmt.Errorf("could not execute request: %w", err) return nil, fmt.Errorf("could not execute request: %w", err)
} }
@@ -402,7 +394,7 @@ func createK8sCloudBrokerLegacy(req k8s_cb.CreateRequest, token string) (*bytes.
} }
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly)) _ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
_ = writer.WriteField("authkey", token) _ = writer.WriteField("authkey", token)
ct := writer.FormDataContentType() ct := writer.FormDataContentType()

View File

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

View File

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

View File

@@ -16,7 +16,7 @@ type SnapshotListRequest struct {
} }
// SnapshotList gets list existing snapshots of the Basic Service // SnapshotList gets list existing snapshots of the Basic Service
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) { func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err)) return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -29,12 +29,12 @@ func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (Li
return nil, err return nil, err
} }
list := ListSnapshots{} list := ListInfoSnapshots{}
err = json.Unmarshal(res, &list) err = json.Unmarshal(res, &list)
if err != nil { if err != nil {
return nil, err 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"` Key string `url:"key" json:"key" validate:"required"`
// Value that must match the key to be taken into account when analyzing this rule // Value that must match the key to be taken into account when analyzing this rule
// Required: true // Required: false
Value string `url:"value" json:"value" validate:"required"` Value string `url:"value" json:"value"`
} }
// AffinityRuleAdd add affinity rule // AffinityRuleAdd add affinity rule

View File

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

View File

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

View File

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

View File

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

View File

@@ -331,9 +331,18 @@ type ItemAffinityGroupComputes struct {
// List of affinity groups // List of affinity groups
type ListAffinityGroupsComputes []ItemAffinityGroupComputes 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 { type ListAffinityGroups struct {
// Data // Data
Data []map[string][]uint64 `json:"data"` Data []map[string]ListAffinityGroup `json:"data"`
// Entry count // Entry count
EntryCount uint64 `json:"entryCount"` EntryCount uint64 `json:"entryCount"`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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