Skip to content

Commit dbbc203

Browse files
Port 16112 bug tf provider returns teams in a non deterministic way causing drift on entity resources (#284)
* add dynamic unknown fields to the blueprint property types * using set instead of list to avoid drifts on ordered lists * using set instead of list to avoid drifts on ordered lists * fix docs * fix docs * fix docs
1 parent b39c78f commit dbbc203

File tree

13 files changed

+64
-63
lines changed

13 files changed

+64
-63
lines changed

docs/data-sources/port_search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Optional:
165165
- `relations` (Attributes) The relations of the entity (see [below for nested schema](#nestedatt--entities--relations))
166166
- `run_id` (String) The runID of the action run that created the entity
167167
- `scorecards` (Map of Object) The scorecards of the entity (see [below for nested schema](#nestedatt--entities--scorecards))
168-
- `teams` (List of String) The teams the entity belongs to
168+
- `teams` (Set of String) The teams the entity belongs to
169169
- `title` (String) The title of the entity
170170

171171
Read-Only:

docs/resources/port_action.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ Optional:
774774
- `identifier` (String) Required when selecting type Upsert Entity. The entity identifier for the upsert
775775
- `properties` (String) The properties of the entity (key-value object encoded to a string)
776776
- `relations` (String) The relations of the entity (key-value object encoded to a string)
777-
- `teams` (List of String) The teams the entity belongs to
777+
- `teams` (Set of String) The teams the entity belongs to
778778
- `teams_jq` (String) Jq that returns the teams the entity belongs to
779779

780780

docs/resources/port_action_permissions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ Required:
250250
Optional:
251251

252252
- `policy` (String) The policy to use for approval
253-
- `roles` (List of String) The roles with approval permission
254-
- `teams` (List of String) The teams with approval permission
255-
- `users` (List of String) The users with approval permission
253+
- `roles` (Set of String) The roles with approval permission
254+
- `teams` (Set of String) The teams with approval permission
255+
- `users` (Set of String) The users with approval permission
256256

257257

258258
<a id="nestedatt--permissions--execute"></a>
@@ -262,6 +262,6 @@ Optional:
262262

263263
- `owned_by_team` (Boolean) Give execution permission to the teams who own the entity
264264
- `policy` (String) The policy to use for execution
265-
- `roles` (List of String) The roles with execution permission
266-
- `teams` (List of String) The teams with execution permission
267-
- `users` (List of String) The users with execution permission
265+
- `roles` (Set of String) The roles with execution permission
266+
- `teams` (Set of String) The teams with execution permission
267+
- `users` (Set of String) The users with execution permission

docs/resources/port_blueprint_permissions.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ Optional:
348348
Optional:
349349

350350
- `owned_by_team` (Boolean) Owned by team
351-
- `roles` (List of String) Roles with register permissions
352-
- `teams` (List of String) Teams with register permissions
353-
- `users` (List of String) Users with register permissions
351+
- `roles` (Set of String) Roles with register permissions
352+
- `teams` (Set of String) Teams with register permissions
353+
- `users` (Set of String) Users with register permissions
354354

355355

356356
<a id="nestedatt--entities--unregister"></a>
@@ -359,9 +359,9 @@ Optional:
359359
Optional:
360360

361361
- `owned_by_team` (Boolean) Owned by team
362-
- `roles` (List of String) Roles with unregister permissions
363-
- `teams` (List of String) Teams with unregister permissions
364-
- `users` (List of String) Users with unregister permissions
362+
- `roles` (Set of String) Roles with unregister permissions
363+
- `teams` (Set of String) Teams with unregister permissions
364+
- `users` (Set of String) Users with unregister permissions
365365

366366

367367
<a id="nestedatt--entities--update"></a>
@@ -370,9 +370,9 @@ Optional:
370370
Optional:
371371

372372
- `owned_by_team` (Boolean) Owned by team
373-
- `roles` (List of String) Roles with update permissions
374-
- `teams` (List of String) Teams with update permissions
375-
- `users` (List of String) Users with update permissions
373+
- `roles` (Set of String) Roles with update permissions
374+
- `teams` (Set of String) Teams with update permissions
375+
- `users` (Set of String) Users with update permissions
376376

377377

378378
<a id="nestedatt--entities--update_metadata_properties"></a>
@@ -391,9 +391,9 @@ Required:
391391
Optional:
392392

393393
- `owned_by_team` (Boolean) Owned by team
394-
- `roles` (List of String) Roles with update `$icon` metadata permissions
395-
- `teams` (List of String) Teams with update `$icon` metadata permissions
396-
- `users` (List of String) Users with update `$icon` metadata permissions
394+
- `roles` (Set of String) Roles with update `$icon` metadata permissions
395+
- `teams` (Set of String) Teams with update `$icon` metadata permissions
396+
- `users` (Set of String) Users with update `$icon` metadata permissions
397397

398398

399399
<a id="nestedatt--entities--update_metadata_properties--identifier"></a>
@@ -402,9 +402,9 @@ Optional:
402402
Optional:
403403

404404
- `owned_by_team` (Boolean) Owned by team
405-
- `roles` (List of String) Roles with update `$identifier` metadata permissions
406-
- `teams` (List of String) Teams with update `$identifier` metadata permissions
407-
- `users` (List of String) Users with update `$identifier` metadata permissions
405+
- `roles` (Set of String) Roles with update `$identifier` metadata permissions
406+
- `teams` (Set of String) Teams with update `$identifier` metadata permissions
407+
- `users` (Set of String) Users with update `$identifier` metadata permissions
408408

409409

410410
<a id="nestedatt--entities--update_metadata_properties--team"></a>
@@ -413,9 +413,9 @@ Optional:
413413
Optional:
414414

415415
- `owned_by_team` (Boolean) Owned by team
416-
- `roles` (List of String) Roles with update `$team` metadata permissions
417-
- `teams` (List of String) Teams with update `$team` metadata permissions
418-
- `users` (List of String) Users with update `$team` metadata permissions
416+
- `roles` (Set of String) Roles with update `$team` metadata permissions
417+
- `teams` (Set of String) Teams with update `$team` metadata permissions
418+
- `users` (Set of String) Users with update `$team` metadata permissions
419419

420420

421421
<a id="nestedatt--entities--update_metadata_properties--title"></a>
@@ -424,9 +424,9 @@ Optional:
424424
Optional:
425425

426426
- `owned_by_team` (Boolean) Owned by team
427-
- `roles` (List of String) Roles with update `$title` metadata permissions
428-
- `teams` (List of String) Teams with update `$title` metadata permissions
429-
- `users` (List of String) Users with update `$title` metadata permissions
427+
- `roles` (Set of String) Roles with update `$title` metadata permissions
428+
- `teams` (Set of String) Teams with update `$title` metadata permissions
429+
- `users` (Set of String) Users with update `$title` metadata permissions
430430

431431

432432

@@ -436,9 +436,9 @@ Optional:
436436
Optional:
437437

438438
- `owned_by_team` (Boolean) Owned by team
439-
- `roles` (List of String) Roles with update specific property permissions
440-
- `teams` (List of String) Teams with update specific property permissions
441-
- `users` (List of String) Users with update specific property permissions
439+
- `roles` (Set of String) Roles with update specific property permissions
440+
- `teams` (Set of String) Teams with update specific property permissions
441+
- `users` (Set of String) Users with update specific property permissions
442442

443443

444444
<a id="nestedatt--entities--update_relations"></a>
@@ -447,6 +447,6 @@ Optional:
447447
Optional:
448448

449449
- `owned_by_team` (Boolean) Owned by team
450-
- `roles` (List of String) Roles with update specific relation permissions
451-
- `teams` (List of String) Teams with update specific relation permissions
452-
- `users` (List of String) Users with update specific relation permissions
450+
- `roles` (Set of String) Roles with update specific relation permissions
451+
- `teams` (Set of String) Teams with update specific relation permissions
452+
- `users` (Set of String) Users with update specific relation permissions

docs/resources/port_entity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Entity resource
2828
- `properties` (Attributes) The properties of the entity (see [below for nested schema](#nestedatt--properties))
2929
- `relations` (Attributes) The relations of the entity (see [below for nested schema](#nestedatt--relations))
3030
- `run_id` (String) The runID of the action run that created the entity
31-
- `teams` (List of String) The teams the entity belongs to
31+
- `teams` (Set of String) The teams the entity belongs to
3232

3333
### Read-Only
3434

docs/resources/port_page_permissions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ resource "port_page_permissions" "microservices_permissions" {
118118

119119
Optional:
120120

121-
- `roles` (List of String) The roles with read permission
122-
- `teams` (List of String) The teams with read permission
123-
- `users` (List of String) The users with read permission
121+
- `roles` (Set of String) The roles with read permission
122+
- `teams` (Set of String) The teams with read permission
123+
- `users` (Set of String) The users with read permission

internal/cli/models.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ func getKnownFields(bp *BlueprintProperty) map[string]bool {
533533
func (bp *BlueprintProperty) UnmarshalJSON(data []byte) error {
534534
// Define an alias to avoid infinite recursion
535535
type Alias BlueprintProperty
536-
537536
// First, unmarshal into the alias to populate known fields
538537
aux := &struct {
539538
*Alias
@@ -563,7 +562,6 @@ func (bp *BlueprintProperty) UnmarshalJSON(data []byte) error {
563562
bp.UnknownFields[key] = value
564563
}
565564
}
566-
567565
return nil
568566
}
569567

port/action-permissions/schema.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package action_permissions
22

33
import (
44
"context"
5+
56
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
67
"github.com/hashicorp/terraform-plugin-framework/attr"
78
"github.com/hashicorp/terraform-plugin-framework/resource"
89
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
910
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
10-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault"
11+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setdefault"
1112
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1213
"github.com/hashicorp/terraform-plugin-framework/types"
1314
)
@@ -35,25 +36,25 @@ func ActionPermissionsSchema() map[string]schema.Attribute {
3536
MarkdownDescription: "The permission to execute the action",
3637
Required: true,
3738
Attributes: map[string]schema.Attribute{
38-
"users": schema.ListAttribute{
39+
"users": schema.SetAttribute{
3940
MarkdownDescription: "The users with execution permission",
4041
Optional: true,
4142
Computed: true,
42-
Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})),
43+
Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})),
4344
ElementType: types.StringType,
4445
},
45-
"roles": schema.ListAttribute{
46+
"roles": schema.SetAttribute{
4647
MarkdownDescription: "The roles with execution permission",
4748
Optional: true,
4849
Computed: true,
49-
Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})),
50+
Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})),
5051
ElementType: types.StringType,
5152
},
52-
"teams": schema.ListAttribute{
53+
"teams": schema.SetAttribute{
5354
MarkdownDescription: "The teams with execution permission",
5455
Optional: true,
5556
Computed: true,
56-
Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})),
57+
Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})),
5758
ElementType: types.StringType,
5859
},
5960
"owned_by_team": schema.BoolAttribute{
@@ -72,25 +73,25 @@ func ActionPermissionsSchema() map[string]schema.Attribute {
7273
MarkdownDescription: "The permission to approve the action's runs",
7374
Required: true,
7475
Attributes: map[string]schema.Attribute{
75-
"users": schema.ListAttribute{
76+
"users": schema.SetAttribute{
7677
MarkdownDescription: "The users with approval permission",
7778
Optional: true,
7879
Computed: true,
79-
Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})),
80+
Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})),
8081
ElementType: types.StringType,
8182
},
82-
"roles": schema.ListAttribute{
83+
"roles": schema.SetAttribute{
8384
MarkdownDescription: "The roles with approval permission",
8485
Optional: true,
8586
Computed: true,
86-
Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})),
87+
Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})),
8788
ElementType: types.StringType,
8889
},
89-
"teams": schema.ListAttribute{
90+
"teams": schema.SetAttribute{
9091
MarkdownDescription: "The teams with approval permission",
9192
Optional: true,
9293
Computed: true,
93-
Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})),
94+
Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})),
9495
ElementType: types.StringType,
9596
},
9697
"policy": schema.StringAttribute{

port/action/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func ActionSchema() map[string]schema.Attribute {
453453
MarkdownDescription: "Required when selecting type Upsert Entity. The entity identifier for the upsert",
454454
Optional: true,
455455
},
456-
"teams": schema.ListAttribute{
456+
"teams": schema.SetAttribute{
457457
MarkdownDescription: "The teams the entity belongs to",
458458
ElementType: types.StringType,
459459
Optional: true,

port/blueprint-permissions/schema.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ import (
1616

1717
func getAssigneeProps(permName string) map[string]schema.Attribute {
1818
return map[string]schema.Attribute{
19-
"users": schema.ListAttribute{
19+
"users": schema.SetAttribute{
2020
MarkdownDescription: fmt.Sprintf("Users with %+v permissions", permName),
2121
Optional: true,
2222
ElementType: types.StringType,
2323
},
24-
"roles": schema.ListAttribute{
24+
"roles": schema.SetAttribute{
2525
MarkdownDescription: fmt.Sprintf("Roles with %+v permissions", permName),
2626
Optional: true,
2727
ElementType: types.StringType,
2828
},
29-
"teams": schema.ListAttribute{
29+
"teams": schema.SetAttribute{
3030
MarkdownDescription: fmt.Sprintf("Teams with %+v permissions", permName),
3131
Optional: true,
3232
ElementType: types.StringType,

0 commit comments

Comments
 (0)