Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-filtering-support-for-twingate_r…
Browse files Browse the repository at this point in the history
…esources-datasource
  • Loading branch information
vmanilo authored Jan 17, 2024
2 parents 5043500 + 0fb349a commit e36c65c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
- "hotfix/**"
paths-ignore:
- 'README.md'

Expand Down
39 changes: 38 additions & 1 deletion twingate/internal/provider/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (r *twingateResource) UpgradeState(ctx context.Context) map[int64]resource.
resp.Diagnostics.Append(resp.State.Set(ctx, upgradedState)...)

resp.Diagnostics.AddWarning("Please update the protocols sections format from a block to an object",
"See the v1 to v2 migration guide in the Twingate Terraform Provider documentation https://registry.terraform.io/providers/Twingate/twingate/latest/docs/guides/migrate-guide-v1-to-v2")
"See the v1 to v2 migration guide in the Twingate Terraform Provider documentation https://registry.terraform.io/providers/Twingate/twingate/latest/docs/guides/migration-v1-to-v2-guide")
},
},
}
Expand Down Expand Up @@ -444,25 +444,62 @@ func accessBlock() schema.ListNestedBlock {
Attributes: map[string]schema.Attribute{
attr.GroupIDs: schema.SetAttribute{
Optional: true,
Computed: true,
ElementType: types.StringType,
Description: "List of Group IDs that will have permission to access the Resource.",
Validators: []validator.Set{
setvalidator.SizeAtLeast(1),
},
PlanModifiers: []planmodifier.Set{
EmptySetDiff(),
},
Default: setdefault.StaticValue(types.SetNull(types.StringType)),
},
attr.ServiceAccountIDs: schema.SetAttribute{
Optional: true,
Computed: true,
ElementType: types.StringType,
Description: "List of Service Account IDs that will have permission to access the Resource.",
Validators: []validator.Set{
setvalidator.SizeAtLeast(1),
},
PlanModifiers: []planmodifier.Set{
EmptySetDiff(),
},
Default: setdefault.StaticValue(types.SetNull(types.StringType)),
},
},
},
}
}

func EmptySetDiff() planmodifier.Set {
return emptySetDiff{}
}

type emptySetDiff struct{}

// Description returns a human-readable description of the plan modifier.
func (m emptySetDiff) Description(_ context.Context) string {
return ""
}

// MarkdownDescription returns a markdown description of the plan modifier.
func (m emptySetDiff) MarkdownDescription(_ context.Context) string {
return ""
}

// PlanModifySet implements the plan modification logic.
func (m emptySetDiff) PlanModifySet(_ context.Context, req planmodifier.SetRequest, resp *planmodifier.SetResponse) {
if req.StateValue.IsNull() {
return
}

if req.ConfigValue.IsNull() && len(req.StateValue.Elements()) == 0 {
resp.PlanValue = req.StateValue
}
}

func PortsDiff() planmodifier.Set {
return portsDiff{}
}
Expand Down

0 comments on commit e36c65c

Please sign in to comment.