diff --git a/CHANGELOG.md b/CHANGELOG.md index 555a82c..3d625d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -## Version 1.6.11 +## Version 1.6.12 -## Bugfix -- Remove tag "required" from field Value in AffinityRuleAddRequest, AntiAffinityRuleAddRequest, AffinityRuleRemoveRequest AntiAffinityRuleRemoveRequest in cloudapi/compute and cloudbroker/compute \ No newline at end of file +### Bugfix +- Fix allowed network plugin value from "weawenet" to "weavenet" in validators for cloudapi/k8s, cloudbroker/k8s and cloudbroker/k8ci +- Delete omitempty from json, url tags in field Permanently in model DeleteRequest in cloudbroker/k8ci and cloudbroker/k8s +- Fix panic in SnapshotList method in cloudapi/bservice +- Fix panic in AffinityGroupsList method in cloudapi/rg \ No newline at end of file diff --git a/client.go b/client.go index 53e3b4e..5e4a66a 100644 --- a/client.go +++ b/client.go @@ -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,7 +174,6 @@ 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)) @@ -281,13 +280,14 @@ 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,5 +394,7 @@ func createK8sCloudBroker(req k8s_cb.CreateRequest) (*bytes.Buffer, string) { _ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly)) ct := writer.FormDataContentType() + + writer.Close() return reqBody, ct } diff --git a/internal/validators/values.go b/internal/validators/values.go index 3082426..c90843f 100644 --- a/internal/validators/values.go +++ b/internal/validators/values.go @@ -39,7 +39,7 @@ var ( sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"} - networkPluginValues = []string{"flannel", "weawenet", "calico"} + networkPluginValues = []string{"flannel", "weavenet", "calico"} strictLooseValues = []string{"strict", "loose"} diff --git a/legacy-client.go b/legacy-client.go index 20795ff..07b07e4 100644 --- a/legacy-client.go +++ b/legacy-client.go @@ -156,11 +156,10 @@ 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 { @@ -175,7 +174,6 @@ 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)) @@ -284,13 +282,14 @@ 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)) @@ -399,5 +398,7 @@ func createK8sCloudBrokerLegacy(req k8s_cb.CreateRequest, token string) (*bytes. _ = writer.WriteField("authkey", token) ct := writer.FormDataContentType() + + writer.Close() return reqBody, ct } diff --git a/pkg/cloudapi/bservice/models.go b/pkg/cloudapi/bservice/models.go index 4432780..7d6c0a6 100644 --- a/pkg/cloudapi/bservice/models.go +++ b/pkg/cloudapi/bservice/models.go @@ -169,6 +169,15 @@ 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 diff --git a/pkg/cloudapi/bservice/snapshot_list.go b/pkg/cloudapi/bservice/snapshot_list.go index efeba00..207a10f 100644 --- a/pkg/cloudapi/bservice/snapshot_list.go +++ b/pkg/cloudapi/bservice/snapshot_list.go @@ -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) (ListSnapshots, error) { +func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, 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) (Li return nil, err } - list := ListSnapshots{} + list := ListInfoSnapshots{} err = json.Unmarshal(res, &list) if err != nil { return nil, err } - return list, nil + return &list, nil } diff --git a/pkg/cloudapi/k8s/create.go b/pkg/cloudapi/k8s/create.go index 8f42d25..6c65d97 100644 --- a/pkg/cloudapi/k8s/create.go +++ b/pkg/cloudapi/k8s/create.go @@ -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, weawenet, calico + // Must be one of these values: flannel, weavenet, calico // Required: true NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"` diff --git a/pkg/cloudapi/rg/models.go b/pkg/cloudapi/rg/models.go index 71849ec..887504d 100644 --- a/pkg/cloudapi/rg/models.go +++ b/pkg/cloudapi/rg/models.go @@ -331,9 +331,18 @@ 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][]uint64 `json:"data"` + Data []map[string]ListAffinityGroup `json:"data"` // Entry count EntryCount uint64 `json:"entryCount"` diff --git a/pkg/cloudbroker/k8ci/create.go b/pkg/cloudbroker/k8ci/create.go index 2b2d9b2..59a1beb 100644 --- a/pkg/cloudbroker/k8ci/create.go +++ b/pkg/cloudbroker/k8ci/create.go @@ -60,7 +60,7 @@ type CreateRequest struct { MaxWorkerCount uint64 `url:"maxWorkerCount" json:"maxWorkerCount" validate:"required"` // Network plugins - // Values of slice must be flannel, weawenet or calico + // Values of slice must be flannel, weavenet or calico //Required: true NetworkPlugins []string `url:"networkPlugins" json:"networkPlugins" validate:"required,networkPlugins"` } diff --git a/pkg/cloudbroker/k8ci/delete.go b/pkg/cloudbroker/k8ci/delete.go index f3393bc..413b922 100644 --- a/pkg/cloudbroker/k8ci/delete.go +++ b/pkg/cloudbroker/k8ci/delete.go @@ -16,7 +16,7 @@ type DeleteRequest struct { // Delete permanently or not // Required: false - Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` + Permanently bool `url:"permanently" json:"permanently"` } // Delete deletes K8CI by ID diff --git a/pkg/cloudbroker/k8s/create.go b/pkg/cloudbroker/k8s/create.go index 5b02abc..55b417b 100644 --- a/pkg/cloudbroker/k8s/create.go +++ b/pkg/cloudbroker/k8s/create.go @@ -29,7 +29,7 @@ type CreateRequest struct { WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"` // Network plugin - // Must be one of these values: flunnel, weawenet, calico + // Must be one of these values: flannel, weavenet, calico // Required: true NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"` diff --git a/pkg/cloudbroker/k8s/delete.go b/pkg/cloudbroker/k8s/delete.go index af3a2ca..e05ba0c 100644 --- a/pkg/cloudbroker/k8s/delete.go +++ b/pkg/cloudbroker/k8s/delete.go @@ -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,omitempty" json:"permanently,omitempty"` + Permanently bool `url:"permanently" json:"permanently"` } // Delete deletes kubernetes cluster