fixed rg recreation when quota is not specified

2.2
kjubybot 3 years ago
parent 8a716edac3
commit 413fb4b82b

@ -24,6 +24,7 @@ Visit https://github.com/rudecs/terraform-provider-decort for full source code p
package decort package decort
import ( import (
"encoding/json"
"fmt" "fmt"
"net/url" "net/url"
@ -122,6 +123,19 @@ func resourceResgroupCreate(d *schema.ResourceData, m interface{}) error {
d.SetId(api_resp) // rg/create API returns ID of the newly creted resource group on success d.SetId(api_resp) // rg/create API returns ID of the newly creted resource group on success
// rg.ID, _ = strconv.Atoi(api_resp) // rg.ID, _ = strconv.Atoi(api_resp)
if !set_quota {
resp, err := utilityResgroupCheckPresence(d, m)
if err != nil {
return err
}
rg := ResgroupGetResp{}
if err := json.Unmarshal([]byte(resp), &rg); err != nil {
return err
}
d.Set("quota", parseQuota(rg.Quota))
}
// re-read newly created RG to make sure schema contains complete and up to date set of specifications // re-read newly created RG to make sure schema contains complete and up to date set of specifications
return resourceResgroupRead(d, m) return resourceResgroupRead(d, m)
@ -166,7 +180,6 @@ func resourceResgroupUpdate(d *schema.ResourceData, m interface{}) error {
return fmt.Errorf("resourceResgroupUpdate: RG ID %s: changing ext_net_id for existing RG is not allowed", d.Id()) return fmt.Errorf("resourceResgroupUpdate: RG ID %s: changing ext_net_id for existing RG is not allowed", d.Id())
} }
do_general_update := false // will be true if general RG update is necessary (API rg/update) do_general_update := false // will be true if general RG update is necessary (API rg/update)
controller := m.(*ControllerCfg) controller := m.(*ControllerCfg)
@ -367,6 +380,7 @@ func resourceResgroup() *schema.Resource {
"quota": { "quota": {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
Computed: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: quotaRgSubresourceSchemaMake(), Schema: quotaRgSubresourceSchemaMake(),

Loading…
Cancel
Save