4.12.2
4.12.2
This commit is contained in:
@@ -37,6 +37,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8ci"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||
)
|
||||
|
||||
func flattenK8CIListItems(list *k8ci.ListK8CI) []map[string]interface{} {
|
||||
@@ -69,6 +70,7 @@ func flattenK8CIItems(d *schema.ResourceData, data *k8ci.RecordK8CI) error {
|
||||
log.Debugf("flattenK8CI: ID %d", data.ID)
|
||||
|
||||
d.Set("desc", data.Description)
|
||||
d.Set("enabled", data.Status == status.Enabled)
|
||||
d.Set("gid", data.GID)
|
||||
d.Set("guid", data.GUID)
|
||||
d.Set("k8ci_id", data.ID)
|
||||
|
||||
@@ -93,22 +93,21 @@ func resourceK8CICreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
if enabled, ok := d.GetOk("enabled"); ok {
|
||||
log.Debugf("resourceK8CICreate: enable=%t k8ci_id %d after completing its resource configuration", enabled, k8ciID)
|
||||
if enabled.(bool) {
|
||||
enabledReq := k8ci.EnableRequest{
|
||||
K8CIID: k8ciID,
|
||||
}
|
||||
if _, err := c.CloudBroker().K8CI().Enable(ctx, enabledReq); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
} else {
|
||||
disableReq := k8ci.DisableRequest{
|
||||
K8CIID: k8ciID,
|
||||
}
|
||||
if _, err := c.CloudBroker().K8CI().Disable(ctx, disableReq); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
enabled := d.Get("enabled").(bool)
|
||||
log.Debugf("resourceK8CICreate: enable=%t k8ci_id %d after completing its resource configuration", enabled, k8ciID)
|
||||
if enabled {
|
||||
enabledReq := k8ci.EnableRequest{
|
||||
K8CIID: k8ciID,
|
||||
}
|
||||
if _, err := c.CloudBroker().K8CI().Enable(ctx, enabledReq); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
} else {
|
||||
disableReq := k8ci.DisableRequest{
|
||||
K8CIID: k8ciID,
|
||||
}
|
||||
if _, err := c.CloudBroker().K8CI().Disable(ctx, disableReq); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,8 +198,8 @@ func resourceK8CIUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if enabled, ok := d.GetOk("enabled"); ok {
|
||||
if enabled.(bool) {
|
||||
if enabled, ok := d.Get("enabled").(bool); ok {
|
||||
if enabled {
|
||||
enabledReq := k8ci.EnableRequest{K8CIID: k8ciRec.ID}
|
||||
_, err := c.CloudBroker().K8CI().Enable(ctx, enabledReq)
|
||||
if err != nil {
|
||||
|
||||
@@ -388,6 +388,7 @@ func resourceK8CISchemaMake() map[string]*schema.Schema {
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
|
||||
Reference in New Issue
Block a user