Skip to content

Commit

Permalink
use float64 of terraform instead of go
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirsegev committed Jul 27, 2023
1 parent 3e4cd26 commit c219f10
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion port/entity/entityResourceToPortBody.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func entityResourceToBody(ctx context.Context, state *EntityModel, bp *cli.Bluep

if state.Properties.NumberProps != nil {
for propIdentifier, prop := range state.Properties.NumberProps {
properties[propIdentifier] = prop
properties[propIdentifier] = prop.ValueFloat64()
}
}

Expand Down
10 changes: 5 additions & 5 deletions port/entity/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ type ArrayPropsModel struct {
}

type EntityPropertiesModel struct {
StringProps map[string]string `tfsdk:"string_props"`
NumberProps map[string]float64 `tfsdk:"number_props"`
BooleanProps map[string]bool `tfsdk:"boolean_props"`
ObjectProps map[string]string `tfsdk:"object_props"`
ArrayProps *ArrayPropsModel `tfsdk:"array_props"`
StringProps map[string]string `tfsdk:"string_props"`
NumberProps map[string]types.Float64 `tfsdk:"number_props"`
BooleanProps map[string]bool `tfsdk:"boolean_props"`
ObjectProps map[string]string `tfsdk:"object_props"`
ArrayProps *ArrayPropsModel `tfsdk:"array_props"`
}

type RelationModel struct {
Expand Down
5 changes: 3 additions & 2 deletions port/entity/refreshEntityState.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"

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

Expand Down Expand Up @@ -56,9 +57,9 @@ func refreshPropertiesEntityState(ctx context.Context, state *EntityModel, e *cl
switch t := v.(type) {
case float64:
if state.Properties.NumberProps == nil {
state.Properties.NumberProps = make(map[string]float64)
state.Properties.NumberProps = make(map[string]types.Float64)
}
state.Properties.NumberProps[k] = float64(t)
state.Properties.NumberProps[k] = basetypes.NewFloat64Value(t)
case string:
if state.Properties.StringProps == nil {
state.Properties.StringProps = make(map[string]string)
Expand Down

0 comments on commit c219f10

Please sign in to comment.