gos_tech_4.4.3 4.3.8
Nikita Sorokin 1 year ago
parent c89574c3e6
commit 739289fbb8

@ -1,6 +1,5 @@
## Version 4.3.7 ## Version 4.3.8
## Bugfix ## Bugfix
- Fixed bug with get request. Update cloudapi/vins - Fixed bugs with restore and newCreate after destroy
- Updated decort-golang-sdk version

@ -7,7 +7,7 @@ ZIPDIR = ./zip
BINARY=${NAME} BINARY=${NAME}
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
MAINPATH = ./cmd/decort/ MAINPATH = ./cmd/decort/
VERSION=4.3.7 VERSION=4.3.8
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
FILES = ${BINARY}_${VERSION}_darwin_amd64\ FILES = ${BINARY}_${VERSION}_darwin_amd64\

@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/sirupsen/logrus v1.9.0 github.com/sirupsen/logrus v1.9.0
golang.org/x/net v0.12.0 golang.org/x/net v0.12.0
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.8 repository.basistech.ru/BASIS/decort-golang-sdk v1.5.10
) )
require ( require (

@ -339,5 +339,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.8 h1:NQ9cEZmWhqXzG3Gxsh0zkQjnqR/HI7JWbN9+EOqGUnE= repository.basistech.ru/BASIS/decort-golang-sdk v1.5.10 h1:LnnOxO8QxSaIfetrzivmRf7qBZJkiakHD0FJLYYAvv8=
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.8/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE= repository.basistech.ru/BASIS/decort-golang-sdk v1.5.10/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=

@ -54,7 +54,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id()) log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id())
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
acc, err := utilityAccountCheckPresence(ctx, d, m) acc, err := utilityAccountCheckPresence(ctx, d, m)
if err != nil { if err != nil {
@ -67,22 +67,23 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac
switch acc.Status { switch acc.Status {
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceAccountCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceAccountCreate(ctx, d, m)
case status.Destroying: case status.Destroying:
return diag.Errorf("The account is in progress with status: %s", acc.Status) return diag.Errorf("The account is in progress with status: %s", acc.Status)
case status.Deleted: case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64) // id, _ := strconv.ParseUint(d.Id(), 10, 64)
req := account.RestoreRequest{ // req := account.RestoreRequest{
AccountID: id, // AccountID: id,
} // }
_, err := c.CloudAPI().Account().Restore(ctx, req) // _, err := c.CloudAPI().Account().Restore(ctx, req)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Disabled: case status.Disabled:
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status) log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
case status.Confirmed: case status.Confirmed:
@ -142,7 +143,8 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
switch acc.Status { switch acc.Status {
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceAccountCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceAccountCreate(ctx, d, m)
case status.Destroying: case status.Destroying:
return diag.Errorf("The account is in progress with status: %s", acc.Status) return diag.Errorf("The account is in progress with status: %s", acc.Status)
case status.Deleted: case status.Deleted:

@ -83,7 +83,7 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceRead") log.Debugf("resourceBasicServiceRead")
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
bs, err := utilityBasicServiceCheckPresence(ctx, d, m) bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
if err != nil { if err != nil {
@ -104,29 +104,30 @@ func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m int
case status.Disabling: case status.Disabling:
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status) log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
case status.Deleted: case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64) // id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := bservice.RestoreRequest{ // restoreReq := bservice.RestoreRequest{
ServiceID: id, // ServiceID: id,
} // }
enableReq := bservice.EnableRequest{ // enableReq := bservice.EnableRequest{
ServiceID: id, // ServiceID: id,
} // }
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq) // _, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
_, err = c.CloudAPI().BService().Enable(ctx, enableReq) // _, err = c.CloudAPI().BService().Enable(ctx, enableReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Deleting: case status.Deleting:
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceBasicServiceCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceBasicServiceCreate(ctx, d, m)
case status.Destroying: case status.Destroying:
return diag.Errorf("The basic service is in progress with status: %s", bs.Status) return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
case status.Restoring: case status.Restoring:
@ -224,7 +225,8 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
case status.Deleting: case status.Deleting:
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceBasicServiceCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceBasicServiceCreate(ctx, d, m)
case status.Destroying: case status.Destroying:
return diag.Errorf("The basic service is in progress with status: %s", bs.Status) return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
case status.Restoring: case status.Restoring:

@ -142,7 +142,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
} }
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
warnings := dc.Warnings{} warnings := dc.Warnings{}
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
@ -157,23 +157,24 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
case status.Destroyed, status.Purged: case status.Destroyed, status.Purged:
d.Set("disk_id", 0) d.Set("disk_id", 0)
d.SetId("") d.SetId("")
return resourceDiskCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted: case status.Deleted:
hasChangeState = true // hasChangeState = true
req := disks.RestoreRequest{ // req := disks.RestoreRequest{
DiskID: disk.ID, // DiskID: disk.ID,
} // }
if reason, ok := d.GetOk("reason"); ok { // if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string) // req.Reason = reason.(string)
} else { // } else {
req.Reason = "Terraform automatic restore" // req.Reason = "Terraform automatic restore"
} // }
_, err := c.CloudAPI().Disks().Restore(ctx, req) // _, err := c.CloudAPI().Disks().Restore(ctx, req)
if err != nil { // if err != nil {
warnings.Add(err) // warnings.Add(err)
} // }
case status.Assigned: case status.Assigned:
case status.Modeled: case status.Modeled:
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status) return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
@ -227,7 +228,8 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
case status.Destroyed, status.Purged: case status.Destroyed, status.Purged:
d.Set("disk_id", 0) d.Set("disk_id", 0)
d.SetId("") d.SetId("")
return resourceDiskCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted: case status.Deleted:
hasChangeState = true hasChangeState = true
req := disks.RestoreRequest{ req := disks.RestoreRequest{

@ -144,7 +144,8 @@ func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{
case status.Created: case status.Created:
case status.Destroyed, status.Purged: case status.Destroyed, status.Purged:
d.SetId("") d.SetId("")
return resourceImageCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceImageCreate(ctx, d, m)
} }
flattenImage(d, img) flattenImage(d, img)
@ -233,7 +234,8 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
case status.Created: case status.Created:
case status.Destroyed, status.Purged: case status.Destroyed, status.Purged:
d.SetId("") d.SetId("")
return resourceImageCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceImageCreate(ctx, d, m)
} }
if d.HasChange("name") { if d.HasChange("name") {

@ -205,31 +205,32 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
case status.Created: case status.Created:
case status.Deleting: case status.Deleting:
case status.Deleted: case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64) // id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := k8s.RestoreRequest{ // restoreReq := k8s.RestoreRequest{
K8SID: id, // K8SID: id,
} // }
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq) // _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
enableReq := k8s.DisableEnableRequest{ // enableReq := k8s.DisableEnableRequest{
K8SID: id, // K8SID: id,
} // }
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq) // _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Destroying: case status.Destroying:
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status) return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceK8sCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling: case status.Enabling:
case status.Enabled: case status.Enabled:
case status.Disabling: case status.Disabling:
@ -388,7 +389,8 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status) return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceK8sCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling: case status.Enabling:
case status.Enabled: case status.Enabled:
case status.Disabling: case status.Disabling:

@ -204,31 +204,32 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
case status.Created: case status.Created:
case status.Deleting: case status.Deleting:
case status.Deleted: case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64) // id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := k8s.RestoreRequest{ // restoreReq := k8s.RestoreRequest{
K8SID: id, // K8SID: id,
} // }
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq) // _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
enableReq := k8s.DisableEnableRequest{ // enableReq := k8s.DisableEnableRequest{
K8SID: id, // K8SID: id,
} // }
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq) // _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Destroying: case status.Destroying:
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status) return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceK8sCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling: case status.Enabling:
case status.Enabled: case status.Enabled:
case status.Disabling: case status.Disabling:
@ -387,7 +388,8 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status) return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceK8sCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling: case status.Enabling:
case status.Enabled: case status.Enabled:
case status.Disabling: case status.Disabling:

@ -496,7 +496,7 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d", log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
d.Get("name").(string), d.Get("rg_id").(int)) d.Get("name").(string), d.Get("rg_id").(int))
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
computeRec, err := utilityComputeCheckPresence(ctx, d, m) computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil { if err != nil {
@ -507,23 +507,24 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
switch computeRec.Status { switch computeRec.Status {
case status.Deleted: case status.Deleted:
restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID} // restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
enableReq := compute.EnableRequest{ComputeID: computeRec.ID} // enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
_, err := c.CloudAPI().Compute().Restore(ctx, restoreReq) // _, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
_, err = c.CloudAPI().Compute().Enable(ctx, enableReq) // _, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceComputeCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceComputeCreate(ctx, d, m)
case status.Disabled: case status.Disabled:
log.Debugf("The compute is in status: %s, troubles may occur with update. Please, enable compute first.", computeRec.Status) log.Debugf("The compute is in status: %s, troubles may occur with update. Please, enable compute first.", computeRec.Status)
case status.Redeploying: case status.Redeploying:
@ -642,7 +643,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceComputeCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceComputeCreate(ctx, d, m)
case status.Disabled: case status.Disabled:
log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", computeRec.Status) log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", computeRec.Status)
case status.Redeploying: case status.Redeploying:

@ -128,7 +128,7 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBRead") log.Debugf("resourceLBRead")
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
lbRec, err := utilityLBCheckPresence(ctx, d, m) lbRec, err := utilityLBCheckPresence(ctx, d, m)
if lbRec == nil { if lbRec == nil {
@ -145,25 +145,26 @@ func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{})
case status.Created: case status.Created:
case status.Deleting: case status.Deleting:
case status.Deleted: case status.Deleted:
lbId, _ := strconv.ParseUint(d.Id(), 10, 64) // lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := lb.RestoreRequest{LBID: lbId} // restoreReq := lb.RestoreRequest{LBID: lbId}
enableReq := lb.DisableEnableRequest{LBID: lbId} // enableReq := lb.DisableEnableRequest{LBID: lbId}
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq) // _, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
_, err = c.CloudAPI().LB().Enable(ctx, enableReq) // _, err = c.CloudAPI().LB().Enable(ctx, enableReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Destroying: case status.Destroying:
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status) return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceLBCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceLBCreate(ctx, d, m)
case status.Enabled: case status.Enabled:
case status.Enabling: case status.Enabling:
case status.Disabling: case status.Disabling:
@ -276,7 +277,8 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status) return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceLBCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceLBCreate(ctx, d, m)
case status.Enabled: case status.Enabled:
case status.Enabling: case status.Enabling:
case status.Disabling: case status.Disabling:

@ -256,7 +256,7 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
log.Debugf("resourceResgroupRead: called for RG name %s, account ID %d", log.Debugf("resourceResgroupRead: called for RG name %s, account ID %d",
d.Get("name").(string), d.Get("account_id").(int)) d.Get("name").(string), d.Get("account_id").(int))
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
rgData, err := utilityResgroupCheckPresence(ctx, d, m) rgData, err := utilityResgroupCheckPresence(ctx, d, m)
if err != nil { if err != nil {
@ -272,24 +272,25 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
case status.Created: case status.Created:
case status.Enabled: case status.Enabled:
case status.Deleted: case status.Deleted:
restoreReq := rg.RestoreRequest{RGID: rgData.ID} // restoreReq := rg.RestoreRequest{RGID: rgData.ID}
enableReq := rg.EnableRequest{RGID: rgData.ID} // enableReq := rg.EnableRequest{RGID: rgData.ID}
_, err := c.CloudAPI().RG().Restore(ctx, restoreReq) // _, err := c.CloudAPI().RG().Restore(ctx, restoreReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
_, err = c.CloudAPI().RG().Enable(ctx, enableReq) // _, err = c.CloudAPI().RG().Enable(ctx, enableReq)
if err != nil { // if err != nil {
return diag.FromErr(err) // return diag.FromErr(err)
} // }
hasChanged = true // hasChanged = true
case status.Deleting: case status.Deleting:
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceResgroupCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceResgroupCreate(ctx, d, m)
case status.Destroying: case status.Destroying:
case status.Disabled: case status.Disabled:
case status.Disabling: case status.Disabling:
@ -369,7 +370,8 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
case status.Deleting: case status.Deleting:
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceResgroupCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceResgroupCreate(ctx, d, m)
case status.Destroying: case status.Destroying:
case status.Disabled: case status.Disabled:
case status.Disabling: case status.Disabling:

@ -240,18 +240,19 @@ func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}
case status.Destroyed: case status.Destroyed:
d.Set("vins_id", 0) d.Set("vins_id", 0)
d.SetId("") d.SetId("")
return resourceVinsCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceVinsCreate(ctx, d, m)
case status.Deleted: case status.Deleted:
hasChangeState = true // hasChangeState = true
req := vins.RestoreRequest{ // req := vins.RestoreRequest{
VINSID: vinsData.ID, // VINSID: vinsData.ID,
} // }
_, err := c.CloudAPI().VINS().Restore(ctx, req) // _, err := c.CloudAPI().VINS().Restore(ctx, req)
if err != nil { // if err != nil {
warnings.Add(err) // warnings.Add(err)
} // }
case status.Modeled: case status.Modeled:
return diag.Errorf("ViNS are in status: %s, please, contact support for more information", vinsData.Status) return diag.Errorf("ViNS are in status: %s, please, contact support for more information", vinsData.Status)
case status.Created: case status.Created:
@ -383,7 +384,8 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
switch vinsData.Status { switch vinsData.Status {
case status.Destroyed: case status.Destroyed:
d.SetId("") d.SetId("")
return resourceVinsCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceVinsCreate(ctx, d, m)
case status.Deleted: case status.Deleted:
hasChangeState = true hasChangeState = true

Loading…
Cancel
Save