You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.5 KiB
42 lines
1.5 KiB
package rg
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform-plugin-framework/diag"
|
|
"github.com/hashicorp/terraform-plugin-log/tflog"
|
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
|
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/ic"
|
|
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/rg/models"
|
|
)
|
|
|
|
func resourceRgInputChecks(ctx context.Context, plan *models.ResourceRGModel, c *decort.DecortClient) diag.Diagnostics {
|
|
diags := diag.Diagnostics{}
|
|
|
|
accountId := uint64(plan.AccountID.ValueInt64())
|
|
tflog.Info(ctx, "resourceRgInputChecks: exist account check", map[string]any{"account_id": accountId})
|
|
err := ic.ExistAccount(ctx, accountId, c)
|
|
if err != nil {
|
|
diags.AddError(fmt.Sprintf("Cannot get info about account with ID %v", accountId), err.Error())
|
|
}
|
|
|
|
gid := uint64(plan.GID.ValueInt64())
|
|
tflog.Info(ctx, "resourceRgInputChecks: exist gid check", map[string]any{"gid": gid})
|
|
err = ic.ExistGID(ctx, gid, c)
|
|
if err != nil {
|
|
diags.AddError(fmt.Sprintf("Cannot get info about gid with ID %v", gid), err.Error())
|
|
}
|
|
|
|
if !plan.ExtNetID.IsNull() {
|
|
extnetId := uint64(plan.ExtNetID.ValueInt64())
|
|
tflog.Info(ctx, "resourceRgInputChecks: exist ext_net check", map[string]any{"ext_net_id": extnetId})
|
|
err = ic.ExistExtNetInRG(ctx, extnetId, accountId, c)
|
|
if err != nil {
|
|
diags.AddError(fmt.Sprintf("Cannot get info about ext net with ID %v", extnetId), err.Error())
|
|
}
|
|
}
|
|
|
|
return diags
|
|
}
|