Skip to content

Commit

Permalink
default map and annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Apr 24, 2024
1 parent 1317e52 commit 183c8f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/common/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func MapFrom(values map[string]any, ctx context.Context, d diag.Diagnostics) types.Map {
if len(values) == 0 {
if values == nil {
return types.MapNull(types.StringType)
}

Expand Down
7 changes: 4 additions & 3 deletions internal/resource/infrastructure_stack_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/mapdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
Expand Down Expand Up @@ -156,7 +157,7 @@ func (r *InfrastructureStackResource) schema() schema.Schema {
ElementType: types.StringType,
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Map{mapplanmodifier.UseStateForUnknown()},
Default: mapdefault.StaticValue(types.MapValueMust(types.StringType, map[string]attr.Value{})),
Validators: []validator.Map{mapvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("raw"))},
},
"annotations": schema.MapAttribute{
Expand All @@ -165,7 +166,7 @@ func (r *InfrastructureStackResource) schema() schema.Schema {
ElementType: types.StringType,
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Map{mapplanmodifier.UseStateForUnknown()},
Default: mapdefault.StaticValue(types.MapValueMust(types.StringType, map[string]attr.Value{})),
Validators: []validator.Map{mapvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("raw"))},
},
"service_account": schema.StringAttribute{
Expand Down

0 comments on commit 183c8f8

Please sign in to comment.