Skip to content

Commit d63067f

Browse files
authored
Merge pull request #218 from port-labs/entity_icon_fix
add icon handle for entity and test
2 parents 6caafb3 + d61e43a commit d63067f

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

internal/cli/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type (
3535
Meta
3636
Identifier string `json:"identifier,omitempty"`
3737
Title string `json:"title"`
38+
Icon string `json:"icon,omitempty"`
3839
Blueprint string `json:"blueprint"`
3940
Team []string `json:"team,omitempty"`
4041
Properties map[string]any `json:"properties"`

port/entity/entityResourceToPortBody.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ func entityResourceToBody(ctx context.Context, state *EntityModel, bp *cli.Bluep
8787
e.Title = state.Title.ValueString()
8888
}
8989

90+
if !state.Icon.IsNull() {
91+
e.Icon = state.Icon.ValueString()
92+
}
93+
9094
if !state.Identifier.IsUnknown() {
9195
e.Identifier = state.Identifier.ValueString()
9296
}

port/entity/refreshEntityToState.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ func refreshEntityState(ctx context.Context, state *EntityModel, e *cli.Entity,
172172
state.Identifier = types.StringValue(e.Identifier)
173173
state.Blueprint = types.StringValue(blueprint.Identifier)
174174
state.Title = types.StringValue(e.Title)
175+
176+
if e.Icon != "" {
177+
state.Icon = types.StringValue(e.Icon)
178+
} else {
179+
state.Icon = types.StringNull()
180+
}
181+
175182
state.CreatedAt = types.StringValue(e.CreatedAt.String())
176183
state.CreatedBy = types.StringValue(e.CreatedBy)
177184
state.UpdatedAt = types.StringValue(e.UpdatedAt.String())

port/entity/resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func TestAccPortEntity(t *testing.T) {
5959
}
6060
resource "port_entity" "microservice" {
6161
title = "TF Provider Test Entity0"
62+
icon = "Terraform"
6263
blueprint = port_blueprint.microservice.identifier
6364
properties = {
6465
"string_props" = {
@@ -100,6 +101,7 @@ func TestAccPortEntity(t *testing.T) {
100101
Config: acctest.ProviderConfig + testAccActionConfigCreate,
101102
Check: resource.ComposeTestCheckFunc(
102103
resource.TestCheckResourceAttr("port_entity.microservice", "title", "TF Provider Test Entity0"),
104+
resource.TestCheckResourceAttr("port_entity.microservice", "icon", "Terraform"),
103105
resource.TestCheckResourceAttr("port_entity.microservice", "blueprint", identifier),
104106
resource.TestCheckResourceAttr("port_entity.microservice", "properties.string_props.myStringIdentifier", "My String Value"),
105107
resource.TestCheckResourceAttr("port_entity.microservice", "properties.number_props.myNumberIdentifier", "123.456"),

0 commit comments

Comments
 (0)