Skip to content

Commit

Permalink
fix: fix issue default_value and help_text unexpected new value (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuyPhanNguyen authored Aug 21, 2024
1 parent 13881dc commit 1e4bcd7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions octopusdeploy_framework/resource_library_variable_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
5 changes: 5 additions & 0 deletions octopusdeploy_framework/schemas/action_template_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/schemas/library_variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 1e4bcd7

Please sign in to comment.