Skip to content

Commit

Permalink
Merge branch 'main' into bp/deployment-process-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
HuyPhanNguyen committed Aug 15, 2024
2 parents 8e93651 + d7fc15c commit 5812ca6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/resources/library_variable_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<a id="nestedblock--template"></a>
Expand Down
4 changes: 1 addition & 3 deletions octopusdeploy_framework/datasource_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 7 additions & 3 deletions octopusdeploy_framework/schemas/library_variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -135,15 +139,15 @@ 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))

for _, actionTemplateParams := range actionTemplateParameters {
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),
Expand Down
8 changes: 8 additions & 0 deletions octopusdeploy_framework/schemas/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package schemas

import (
"fmt"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"

Check failure on line 5 in octopusdeploy_framework/schemas/schema.go

View workflow job for this annotation

GitHub Actions / build

other declaration of planmodifier

Check failure on line 5 in octopusdeploy_framework/schemas/schema.go

View workflow job for this annotation

GitHub Actions / build

other declaration of planmodifier
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"

Check failure on line 6 in octopusdeploy_framework/schemas/schema.go

View workflow job for this annotation

GitHub Actions / build

other declaration of stringplanmodifier

Check failure on line 6 in octopusdeploy_framework/schemas/schema.go

View workflow job for this annotation

GitHub Actions / build

other declaration of stringplanmodifier

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand Down Expand Up @@ -147,6 +149,9 @@ func GetIdResourceSchema() resourceSchema.Attribute {
Description: "The unique ID for this resource.",
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
}
}

Expand All @@ -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(),
},
}
}

Expand Down

0 comments on commit 5812ca6

Please sign in to comment.