From 12f3b91166903396ca2ae589967f11a943f9fb0d Mon Sep 17 00:00:00 2001 From: Vitaly Antonenko Date: Wed, 29 May 2024 11:37:37 +0300 Subject: [PATCH] feat(application): define schema for storage flag in application resource This commit extends the application schema to support the storage flag in the Terraform provider for Juju. The schema now includes varios attributes for configuring the storage constraints of a Juju application. --- internal/provider/resource_application.go | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/internal/provider/resource_application.go b/internal/provider/resource_application.go index 89703d6c..07db1b5b 100644 --- a/internal/provider/resource_application.go +++ b/internal/provider/resource_application.go @@ -6,6 +6,7 @@ package provider import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "strings" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" @@ -164,6 +165,34 @@ func (r *applicationResource) Schema(_ context.Context, _ resource.SchemaRequest stringplanmodifier.UseStateForUnknown(), }, }, + "storage": schema.SetNestedAttribute{ + Description: "Configure storage constraints for the juju application.", + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "label": schema.StringAttribute{ + Description: "The specific storage option defined in the charm.", + Required: true, + }, + "size": schema.StringAttribute{ + Description: "The size of each volume. E.g. 100G.", + Required: true, + }, + "pool": schema.StringAttribute{ + Description: "Name of the storage pool to use. E.g. ebs on aws.", + Optional: true, + }, + "count": schema.Int64Attribute{ + Description: "The number of volumes.", + Optional: true, + }, + }, + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.RequiresReplaceIfConfigured(), + objectplanmodifier.UseStateForUnknown(), + }, + }, + }, "trust": schema.BoolAttribute{ Description: "Set the trust for the application.", Optional: true,