diff --git a/docs/resources/library_variable_set.md b/docs/resources/library_variable_set.md index 9bff4bf78..1eac0caca 100644 --- a/docs/resources/library_variable_set.md +++ b/docs/resources/library_variable_set.md @@ -25,10 +25,10 @@ This resource manages library variable sets in Octopus Deploy. - `id` (String) The unique ID for this resource. - `space_id` (String) The space ID associated with this library variable set. - `template` (Block List) (see [below for nested schema](#nestedblock--template)) -- `template_ids` (Map of String) ### Read-Only +- `template_ids` (Map of String) - `variable_set_id` (String) diff --git a/octopusdeploy_framework/datasource_environments.go b/octopusdeploy_framework/datasource_environments.go index 13f884e74..da219658c 100644 --- a/octopusdeploy_framework/datasource_environments.go +++ b/octopusdeploy_framework/datasource_environments.go @@ -84,9 +84,7 @@ func (e *environmentDataSource) Read(ctx context.Context, req datasource.ReadReq Take: util.GetNumber(data.Take), } - spaceID := util.Ternary(data.SpaceID.IsNull(), e.Client.GetSpaceID(), data.SpaceID.ValueString()) - - existingEnvironments, err := environments.Get(e.Client, spaceID, query) + existingEnvironments, err := environments.Get(e.Client, data.SpaceID.ValueString(), query) if err != nil { resp.Diagnostics.AddError("unable to load environments", err.Error()) return diff --git a/octopusdeploy_framework/resource_variable.go b/octopusdeploy_framework/resource_variable.go index 78d48b5a2..af4e5b775 100644 --- a/octopusdeploy_framework/resource_variable.go +++ b/octopusdeploy_framework/resource_variable.go @@ -211,7 +211,7 @@ func (r *variableTypeResource) Delete(ctx context.Context, req resource.DeleteRe return } - if _, err := variables.DeleteSingle(r.Config.Client, r.Config.SpaceID, variableOwnerID.ValueString(), data.ID.ValueString()); err != nil { + if _, err := variables.DeleteSingle(r.Config.Client, data.SpaceID.ValueString(), variableOwnerID.ValueString(), data.ID.ValueString()); err != nil { resp.Diagnostics.AddError("unable to delete variable", err.Error()) return } diff --git a/octopusdeploy_framework/schemas/library_variable_set.go b/octopusdeploy_framework/schemas/library_variable_set.go index 76ba84d14..055db386c 100644 --- a/octopusdeploy_framework/schemas/library_variable_set.go +++ b/octopusdeploy_framework/schemas/library_variable_set.go @@ -7,6 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" types "github.com/hashicorp/terraform-plugin-framework/types" ) @@ -93,10 +95,12 @@ func GetLibraryVariableSetResourceSchema() resourceSchema.Schema { "template_ids": resourceSchema.MapAttribute{ ElementType: types.StringType, Computed: true, - Optional: true, }, "variable_set_id": resourceSchema.StringAttribute{ Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, }, }, Description: "This resource manages library variable sets in Octopus Deploy.", @@ -135,7 +139,7 @@ func MapToLibraryVariableSet(data *LibraryVariableSetResourceModel) *variables.L func FlattenTemplates(actionTemplateParameters []actiontemplates.ActionTemplateParameter) types.List { if len(actionTemplateParameters) == 0 { - return types.ListNull(types.ObjectType{AttrTypes: TemplateObjectType()}) + return types.ListValueMust(types.ObjectType{AttrTypes: TemplateObjectType()}, []attr.Value{}) } actionTemplateList := make([]attr.Value, 0, len(actionTemplateParameters)) @@ -143,7 +147,7 @@ func FlattenTemplates(actionTemplateParameters []actiontemplates.ActionTemplateP attrs := map[string]attr.Value{ "default_value": util.Ternary(actionTemplateParams.DefaultValue.Value != "", types.StringValue(actionTemplateParams.DefaultValue.Value), types.StringNull()), "display_settings": flattenDisplaySettingsMap(actionTemplateParams.DisplaySettings), - "help_text": util.Ternary(actionTemplateParams.HelpText != "", types.StringValue(actionTemplateParams.HelpText), types.StringNull()), + "help_text": util.Ternary(actionTemplateParams.HelpText != "", types.StringValue(actionTemplateParams.HelpText), types.StringValue("")), "id": types.StringValue(actionTemplateParams.GetID()), "label": util.Ternary(actionTemplateParams.Label != "", types.StringValue(actionTemplateParams.Label), types.StringNull()), "name": types.StringValue(actionTemplateParams.Name), diff --git a/octopusdeploy_framework/schemas/schema.go b/octopusdeploy_framework/schemas/schema.go index fdb077380..23d793311 100644 --- a/octopusdeploy_framework/schemas/schema.go +++ b/octopusdeploy_framework/schemas/schema.go @@ -2,6 +2,8 @@ package schemas import ( "fmt" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -147,6 +149,9 @@ func GetIdResourceSchema() resourceSchema.Attribute { Description: "The unique ID for this resource.", Computed: true, Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, } } @@ -155,6 +160,9 @@ func GetSpaceIdResourceSchema(resourceDescription string) resourceSchema.Attribu Description: "The space ID associated with this " + resourceDescription + ".", Computed: true, Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, } }