From f5e0a5336452df38c5aa876c180ceaff84e06e6c Mon Sep 17 00:00:00 2001 From: KasimBaybikov Date: Thu, 16 Feb 2023 16:29:04 +0300 Subject: [PATCH] 3.4.3 --- CHANGELOG.md | 17 +++++---- .../cloudapi/account/data_source_account.go | 4 +-- .../account/data_source_account_rg_list.go | 35 +++++++++++++++++-- internal/service/cloudapi/account/models.go | 17 ++++++--- .../cloudapi/account/resource_account.go | 4 +-- internal/service/cloudapi/rg/models.go | 14 ++++---- 6 files changed, 64 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d51c21..9fe835b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,11 @@ -### Version 3.4.2 +### Version 3.4.3 -### Bug fixes +### Features -- Change field type size_used from int to float in: - - resource decort_kvmvm - - resource decort_disk - - data source decort_kvmvm - - data source decort_disk - - data source decort_disk_list - - data source decort_disk_list-unattached +- Change field type disksize from int to float in: + - resource decort_resgroup + - resource decort_account + - data source decort_rg + - data source decort_account + - data source decort_account_rg_list - Models of the resources diff --git a/internal/service/cloudapi/account/data_source_account.go b/internal/service/cloudapi/account/data_source_account.go index fada58c..8471b49 100644 --- a/internal/service/cloudapi/account/data_source_account.go +++ b/internal/service/cloudapi/account/data_source_account.go @@ -198,7 +198,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Computed: true, }, "disksize": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Computed: true, }, "extips": { @@ -254,7 +254,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Computed: true, }, "disksize": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Computed: true, }, "extips": { diff --git a/internal/service/cloudapi/account/data_source_account_rg_list.go b/internal/service/cloudapi/account/data_source_account_rg_list.go index 42fa18e..5dfaffa 100644 --- a/internal/service/cloudapi/account/data_source_account_rg_list.go +++ b/internal/service/cloudapi/account/data_source_account_rg_list.go @@ -74,12 +74,41 @@ func flattenAccRGComputes(argc AccountRGComputes) []map[string]interface{} { return res } +func flattenAccResourceHack(r ResourceHack) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "cpu": r.CPU, + "disksize": r.Disksize, + "extips": r.Extips, + "exttraffic": r.Exttraffic, + "gpu": r.GPU, + "ram": r.RAM, + //"seps": flattenAccountSeps(r.SEPs), + } + res = append(res, temp) + return res +} + +func flattenAccResourceRg(r Resource) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "cpu": r.CPU, + "disksize": r.Disksize, + "extips": r.Extips, + "exttraffic": r.Exttraffic, + "gpu": r.GPU, + "ram": r.RAM, + } + res = append(res, temp) + return res +} + func flattenAccRGResources(argr AccountRGResources) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "consumed": flattenAccResource(argr.Consumed), - "limits": flattenAccResource(argr.Limits), - "reserved": flattenAccResource(argr.Reserved), + "consumed": flattenAccResourceRg(argr.Consumed), + "limits": flattenAccResourceHack(argr.Limits), + "reserved": flattenAccResourceRg(argr.Reserved), } res = append(res, temp) return res diff --git a/internal/service/cloudapi/account/models.go b/internal/service/cloudapi/account/models.go index 764cb42..6c5dda9 100644 --- a/internal/service/cloudapi/account/models.go +++ b/internal/service/cloudapi/account/models.go @@ -96,7 +96,7 @@ type ResourceSep struct { type Resource struct { CPU int `json:"cpu"` - Disksize int `json:"disksize"` + Disksize float64 `json:"disksize"` Extips int `json:"extips"` Exttraffic int `json:"exttraffic"` GPU int `json:"gpu"` @@ -201,10 +201,19 @@ type AccountRGComputes struct { Stopped int `json:"Stopped"` } +type ResourceHack struct { + CPU int `json:"cpu"` + Disksize float64 `json:"disksize"` + Extips int `json:"extips"` + Exttraffic int `json:"exttraffic"` + GPU int `json:"gpu"` + RAM int `json:"ram"` +} + type AccountRGResources struct { - Consumed Resource `json:"Consumed"` - Limits Resource `json:"Limits"` - Reserved Resource `json:"Reserved"` + Consumed Resource `json:"Consumed"` + Limits ResourceHack `json:"Limits"` + Reserved Resource `json:"Reserved"` } type AccountRG struct { diff --git a/internal/service/cloudapi/account/resource_account.go b/internal/service/cloudapi/account/resource_account.go index c826bce..ae1fb3f 100644 --- a/internal/service/cloudapi/account/resource_account.go +++ b/internal/service/cloudapi/account/resource_account.go @@ -574,7 +574,7 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Computed: true, }, "disksize": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Computed: true, }, "extips": { @@ -630,7 +630,7 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Computed: true, }, "disksize": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Computed: true, }, "extips": { diff --git a/internal/service/cloudapi/rg/models.go b/internal/service/cloudapi/rg/models.go index 0db7022..a0fb4cc 100644 --- a/internal/service/cloudapi/rg/models.go +++ b/internal/service/cloudapi/rg/models.go @@ -137,12 +137,12 @@ type QuotaRecord struct { // this is how quota is reported by /api/.../rg/get } type ResourceRecord struct { // this is how actual usage is reported by /api/.../rg/get - Cpu int `json:"cpu"` - Disk int `json:"disksize"` - ExtIPs int `json:"extips"` - ExtTraffic int `json:"exttraffic"` - Gpu int `json:"gpu"` - Ram int `json:"ram"` + Cpu int `json:"cpu"` + Disk float64 `json:"disksize"` + ExtIPs int `json:"extips"` + ExtTraffic int `json:"exttraffic"` + Gpu int `json:"gpu"` + Ram int `json:"ram"` } type UsageRecord struct { @@ -157,7 +157,7 @@ type ResourceSep struct { type Resource struct { CPU int `json:"cpu"` - Disksize int `json:"disksize"` + Disksize float64 `json:"disksize"` Extips int `json:"extips"` Exttraffic int `json:"exttraffic"` GPU int `json:"gpu"`