From c5f7f8868bc62911fce248225c4979907bce19db Mon Sep 17 00:00:00 2001 From: Volodymyr Manilo <35466116+vmanilo@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:17:34 +0200 Subject: [PATCH 1/3] fix url address (#450) --- twingate/internal/provider/resource/resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twingate/internal/provider/resource/resource.go b/twingate/internal/provider/resource/resource.go index d2490869..90b98ff8 100644 --- a/twingate/internal/provider/resource/resource.go +++ b/twingate/internal/provider/resource/resource.go @@ -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") }, }, } From d022d52499d1ca1219f08f80345d5aca59fbc52a Mon Sep 17 00:00:00 2001 From: Volodymyr Manilo <35466116+vmanilo@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:14:03 +0200 Subject: [PATCH 2/3] Fix: resource migration v0 to v1 (#452) * fix: handle empty list in access block * enable tests * revert ci changes --- .../internal/provider/resource/resource.go | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/twingate/internal/provider/resource/resource.go b/twingate/internal/provider/resource/resource.go index 90b98ff8..5c65140e 100644 --- a/twingate/internal/provider/resource/resource.go +++ b/twingate/internal/provider/resource/resource.go @@ -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{} } From 0fb349a8a427167332a0f7885d37f37e4c0af248 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Tue, 16 Jan 2024 14:43:14 -0800 Subject: [PATCH 3/3] Run CI for hotfixes --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b96c31dc..f6931298 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - main + - "hotfix/**" paths-ignore: - 'README.md'