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.

32 lines
1.1 KiB

package k8ci
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-log/tflog"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/ic"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/k8ci/models"
)
func resourceK8CIInputChecks(ctx context.Context, plan *models.ResourceK8CIModel, c *client.Client) diag.Diagnostics {
diags := diag.Diagnostics{}
masterImageId := uint64(plan.MasterImageId.ValueInt64())
workerImageId := uint64(plan.WorkerImageId.ValueInt64())
images := make([]uint64, 0)
images = append(images, masterImageId)
if workerImageId != masterImageId {
images = append(images, workerImageId)
}
tflog.Info(ctx, "resourceK8CIInputChecks: exist images check", map[string]any{"master_image_id": masterImageId, "worker_image_id": workerImageId})
err := ic.ExistImages(ctx, images, c)
if err != nil {
diags.AddError(fmt.Sprintf("Cannot get info about images"), err.Error())
}
return diags
}