Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the colors mapping to blueprint in calculation property #189

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion port/blueprint/readStateToPortBody.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package blueprint
import (
"context"

"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/port-labs/terraform-provider-port-labs/v2/internal/cli"
)

Expand Down Expand Up @@ -130,7 +131,9 @@ func calculationPropertiesToBody(ctx context.Context, state *BlueprintModel) map
if !prop.Colors.IsNull() {
colors := make(map[string]string)
for key, value := range prop.Colors.Elements() {
colors[key] = value.String()
if stringValue, ok := value.(basetypes.StringValue); ok {
colors[key] = stringValue.ValueString()
}
}

calculationProp.Colors = colors
Expand Down
7 changes: 7 additions & 0 deletions port/blueprint/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@ func TestAccPortBlueprintWithCalculationProperty(t *testing.T) {
calculation = "test-rel.$identifier"
type = "string"
icon = "Terraform"
colors = {
"test1" = "red"
"test2" = "blue"
"test3" = "green"
"test4" = "yellow"
}
}
}
}`, identifier1)
Expand All @@ -686,6 +692,7 @@ func TestAccPortBlueprintWithCalculationProperty(t *testing.T) {
resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.title", "Calculation for microservice1"),
resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.calculation", "test-rel.$identifier"),
resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.icon", "Terraform"),
resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.colors.test2", "blue"),
),
},
},
Expand Down
Loading