Skip to content

Commit 259d816

Browse files
authored
add team field to entity (#10)
1 parent 306ed4d commit 259d816

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

docs/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ description: |-
1515
<!-- schema generated by tfplugindocs -->
1616
## Schema
1717

18-
### Optional
18+
### Required
1919

20-
- `base_url` (String)
2120
- `client_id` (String)
2221
- `secret` (String, Sensitive)
22+
23+
### Optional
24+
25+
- `base_url` (String)
2326
- `token` (String, Sensitive)

docs/resources/entity.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Port entity
2525

2626
- `identifier` (String) The identifier of the entity
2727
- `relations` (Block Set) The other entities that are connected (see [below for nested schema](#nestedblock--relations))
28+
- `team` (String) The team related to the entity
2829

2930
### Read-Only
3031

port/cli/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type (
2222
Identifier string `json:"identifier,omitempty"`
2323
Title string `json:"title"`
2424
Blueprint string `json:"blueprint"`
25+
Team string `json:"team,omitempty"`
2526
Properties map[string]interface{} `json:"properties"`
2627
Relations map[string]string `json:"relations"`
2728
// TODO: add the rest of the fields.

port/resource_port_entity.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func newEntityResource() *schema.Resource {
3030
Description: "The display name of the entity",
3131
Required: true,
3232
},
33+
"team": {
34+
Type: schema.TypeString,
35+
Description: "The team related to the entity",
36+
Optional: true,
37+
},
3338
"blueprint": {
3439
Type: schema.TypeString,
3540
Description: "The blueprint identifier the entity relates to",
@@ -154,6 +159,9 @@ func entityResourceToBody(d *schema.ResourceData, bp *cli.Blueprint) (*cli.Entit
154159
}
155160
e.Title = d.Get("title").(string)
156161
e.Blueprint = d.Get("blueprint").(string)
162+
if team, ok := d.GetOk("team"); ok {
163+
e.Team = team.(string)
164+
}
157165
rels := d.Get("relations").(*schema.Set)
158166
relations := make(map[string]string)
159167
for _, rel := range rels.List() {
@@ -186,6 +194,7 @@ func writeEntityComputedFieldsToResource(d *schema.ResourceData, e *cli.Entity)
186194
func writeEntityFieldsToResource(d *schema.ResourceData, e *cli.Entity) {
187195
d.SetId(e.Identifier)
188196
d.Set("title", e.Title)
197+
d.Set("team", e.Team)
189198
d.Set("created_at", e.CreatedAt.String())
190199
d.Set("created_by", e.CreatedBy)
191200
d.Set("updated_at", e.UpdatedAt.String())

port/resource_port_entity_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestAccPortEntityUpdateProp(t *testing.T) {
2525
resource "port-labs_entity" "microservice" {
2626
title = "monolith"
2727
blueprint = port-labs_blueprint.tf_bp.id
28+
team = "Everyone"
2829
properties {
2930
name = "text"
3031
value = "hedwig"
@@ -45,6 +46,7 @@ func TestAccPortEntityUpdateProp(t *testing.T) {
4546
}
4647
resource "port-labs_entity" "microservice" {
4748
title = "monolith"
49+
team = "Everyone"
4850
blueprint = port-labs_blueprint.tf_bp.id
4951
properties {
5052
name = "text"
@@ -59,10 +61,23 @@ func TestAccPortEntityUpdateProp(t *testing.T) {
5961
Steps: []resource.TestStep{
6062
{
6163
Config: testAccActionConfigCreate,
64+
Check: resource.ComposeTestCheckFunc(
65+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "title", "monolith"),
66+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "team", "Everyone"),
67+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "properties.0.name", "text"),
68+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "properties.0.value", "hedwig"),
69+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "blueprint", identifier),
70+
),
6271
},
6372
{
6473
Config: testAccActionConfigUpdate,
65-
Check: resource.TestCheckResourceAttr("port-labs_entity.microservice", "properties.0.value", "hedwig2"),
74+
Check: resource.ComposeTestCheckFunc(
75+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "title", "monolith"),
76+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "team", "Everyone"),
77+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "properties.0.name", "text"),
78+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "properties.0.value", "hedwig2"),
79+
resource.TestCheckResourceAttr("port-labs_entity.microservice", "blueprint", identifier),
80+
),
6681
},
6782
},
6883
})

0 commit comments

Comments
 (0)