From 1e4bcd7713fa7220c1308454fee03e75b5ec681d Mon Sep 17 00:00:00 2001 From: Huy Nguyen <162080607+HuyPhanNguyen@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:38:34 +1000 Subject: [PATCH] fix: fix issue default_value and help_text unexpected new value (#760) --- .../resource_library_variable_set_test.go | 7 +++++++ .../schemas/action_template_parameter.go | 5 +++++ octopusdeploy_framework/schemas/library_variable_set.go | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/octopusdeploy_framework/resource_library_variable_set_test.go b/octopusdeploy_framework/resource_library_variable_set_test.go index 7d42c680f..b167b4593 100644 --- a/octopusdeploy_framework/resource_library_variable_set_test.go +++ b/octopusdeploy_framework/resource_library_variable_set_test.go @@ -169,6 +169,13 @@ func testLibraryVariableSetWithVariable(localName, variableLocalName, name, desc resource "octopusdeploy_library_variable_set" "%s" { name = "%s" description = "%s" + + template { + name = "template" + # help_text = "" + default_value = "" + display_settings = { "Octopus.ControlType" = "SingleLineText" } + } } resource "octopusdeploy_variable" "%s" { diff --git a/octopusdeploy_framework/schemas/action_template_parameter.go b/octopusdeploy_framework/schemas/action_template_parameter.go index 54593261b..bee1f1262 100644 --- a/octopusdeploy_framework/schemas/action_template_parameter.go +++ b/octopusdeploy_framework/schemas/action_template_parameter.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" 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/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -72,6 +73,8 @@ func GetActionTemplateParameterSchema() map[string]resourceSchema.Attribute { "default_value": resourceSchema.StringAttribute{ Description: "A default value for the parameter, if applicable. This can be a hard-coded value or a variable reference.", Optional: true, + Computed: true, + Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -84,6 +87,8 @@ func GetActionTemplateParameterSchema() map[string]resourceSchema.Attribute { "help_text": resourceSchema.StringAttribute{ Description: "The help presented alongside the parameter input.", Optional: true, + Computed: true, + Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, diff --git a/octopusdeploy_framework/schemas/library_variable_set.go b/octopusdeploy_framework/schemas/library_variable_set.go index 055db386c..efec16d39 100644 --- a/octopusdeploy_framework/schemas/library_variable_set.go +++ b/octopusdeploy_framework/schemas/library_variable_set.go @@ -145,7 +145,7 @@ func FlattenTemplates(actionTemplateParameters []actiontemplates.ActionTemplateP for _, actionTemplateParams := range actionTemplateParameters { attrs := map[string]attr.Value{ - "default_value": util.Ternary(actionTemplateParams.DefaultValue.Value != "", types.StringValue(actionTemplateParams.DefaultValue.Value), types.StringNull()), + "default_value": types.StringValue(actionTemplateParams.DefaultValue.Value), "display_settings": flattenDisplaySettingsMap(actionTemplateParams.DisplaySettings), "help_text": util.Ternary(actionTemplateParams.HelpText != "", types.StringValue(actionTemplateParams.HelpText), types.StringValue("")), "id": types.StringValue(actionTemplateParams.GetID()),