terraform-provider: validate microservice and image version during plan (#2814)

This commit is contained in:
Adrian Stobbe 2024-01-11 12:04:21 +01:00 committed by GitHub
parent baad7d8310
commit 9a814f91b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 32 deletions

View file

@ -460,6 +460,18 @@ func (r *ClusterResource) ModifyPlan(ctx context.Context, req resource.ModifyPla
"For details, see https://docs.edgeless.systems/constellation/overview/license")
}
// Validate during plan. Must be done in ModifyPlan to read provider data.
// See https://developer.hashicorp.com/terraform/plugin/framework/resources/configure#define-resource-configure-method.
_, diags := r.getMicroserviceVersion(&plannedState)
resp.Diagnostics.Append(diags...)
_, _, diags = r.getImageVersion(ctx, &plannedState)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
// Checks running on updates to the resource. (i.e. state and plan != nil)
if !req.State.Raw.IsNull() {
// Read currentState supplied by Terraform runtime into the model