This commit is contained in:
asteam
2024-12-04 13:18:58 +03:00
parent 003e4d656e
commit 76ea459b3d
417 changed files with 30051 additions and 975 deletions

View File

@@ -91,7 +91,7 @@ func LBEnableDisable(ctx context.Context, plan *models.ResourceLBModel, c *decor
diags.AddError("Cannot parsed ID lb from state", err.Error())
return diags
}
if plan.Enable.IsNull() || plan.Enable.ValueBool() {
if plan.Enable.ValueBool() {
tflog.Info(ctx, "Enable lb with ID", map[string]any{"lb_id": plan.ID.ValueString()})
_, err := c.CloudAPI().LB().Enable(ctx, lb.DisableEnableRequest{LBID: lbId})
if err != nil {
@@ -131,7 +131,7 @@ func LBReadStatus(ctx context.Context, plan *models.ResourceLBModel, c *decort.D
diags.AddError("Error:", fmt.Sprintf("The lb is in status: %s, please, contact support for more information", lbItem.Status))
return diags
case status.Deleted:
if plan.Restore.ValueBool() || plan.Restore.IsNull() {
if plan.Restore.ValueBool() {
diags = LBRestore(ctx, plan, c)
if diags.HasError() {
tflog.Error(ctx, "Error restore lb", map[string]any{"lb_id": plan.ID.ValueString()})
@@ -141,7 +141,7 @@ func LBReadStatus(ctx context.Context, plan *models.ResourceLBModel, c *decort.D
diags.AddError("LB in status Deleted:", "please clean state, or restore lb")
return diags
}
if plan.Enable.ValueBool() || plan.Enable.IsNull() {
if plan.Enable.ValueBool() {
diags = LBEnableDisable(ctx, plan, c)
if diags.HasError() {
tflog.Error(ctx, "Error enable/disable lb", map[string]any{"lb_id": plan.ID.ValueString()})
@@ -196,7 +196,7 @@ func LBStartStop(ctx context.Context, plan *models.ResourceLBModel, c *decort.De
diags.AddError("Cannot parsed ID lb from state", err.Error())
return diags
}
if plan.Enable.IsNull() || plan.Enable.ValueBool() {
if plan.Enable.ValueBool() {
if plan.Start.ValueBool() || plan.Start.IsNull() {
tflog.Info(ctx, "Start lb with ID", map[string]any{"lb_id": plan.ID.ValueString()})
_, err := c.CloudAPI().LB().Start(ctx, lb.StartRequest{LBID: lbId})
@@ -206,7 +206,7 @@ func LBStartStop(ctx context.Context, plan *models.ResourceLBModel, c *decort.De
}
}
}
if plan.Enable.ValueBool() || plan.Enable.IsNull() {
if plan.Enable.ValueBool() {
tflog.Info(ctx, "Stop lb with ID", map[string]any{"lb_id": plan.ID.ValueString()})
if !plan.Start.ValueBool() && !plan.Start.IsNull() {
_, err := c.CloudAPI().LB().Stop(ctx, lb.StopRequest{LBID: lbId})