diff --git a/docs/resources/action.md b/docs/resources/action.md index b9bbb9e7..5da81871 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -27,7 +27,6 @@ Port action - `description` (String) The description of the action - `icon` (String) The icon of the action -- `required_properties` (Set of String) The required properties of the action - `user_properties` (Block Set) The input properties of the action (see [below for nested schema](#nestedblock--user_properties)) ### Read-Only @@ -57,9 +56,12 @@ Required: Optional: +- `blueprint` (String) When selecting format 'entity', the identifier of the target blueprint - `default` (String) A default value for this property in case an entity is created without explicitly providing a value. - `description` (String) A description of the property. This value is visible to users when hovering on the info icon in the UI. It provides detailed information about the use of a specific property. +- `enum` (List of String) A list of allowed values for the property - `format` (String) A specific data format to pair with some of the available types - `pattern` (String) A regular expression (regex) pattern to specify the set of allowed values for the property +- `required` (Boolean) Whether the property is required or not diff --git a/docs/resources/blueprint.md b/docs/resources/blueprint.md index a8081709..b2c41799 100644 --- a/docs/resources/blueprint.md +++ b/docs/resources/blueprint.md @@ -26,6 +26,9 @@ Port blueprint - `changelog_destination` (Block List, Max: 1) Blueprints changelog destination, Supports WEBHOOK and KAFKA (see [below for nested schema](#nestedblock--changelog_destination)) - `data_source` (String, Deprecated) The data source for entities of this blueprint +- `description` (String) The description of the blueprint +- `formula_properties` (Block Set) A property that is calculated by a formula (see [below for nested schema](#nestedblock--formula_properties)) +- `mirror_properties` (Block Set) When two Blueprints are connected via a Relation, a new set of properties becomes available to Entities in the source Blueprint. (see [below for nested schema](#nestedblock--mirror_properties)) - `relations` (Block Set) The blueprints that are connected to this blueprint (see [below for nested schema](#nestedblock--relations)) ### Read-Only @@ -49,7 +52,11 @@ Optional: - `default` (String) The default value of the property - `description` (String) The description of the property +- `enum` (List of String) A list of allowed values for the property +- `enum_colors` (Map of String) A map of colors for the enum values - `format` (String) The format of the Property +- `icon` (String) The icon of the property +- `required` (Boolean) Whether or not the property is required @@ -64,6 +71,32 @@ Optional: - `url` (String) Required when selecting type WEBHOOK. The URL to which the changelog is dispatched + +### Nested Schema for `formula_properties` + +Required: + +- `formula` (String) The path of the realtions towards the property +- `identifier` (String) The identifier of the property + +Optional: + +- `title` (String) The name of this property + + + +### Nested Schema for `mirror_properties` + +Required: + +- `identifier` (String) The identifier of the property +- `path` (String) The path of the realtions towards the property + +Optional: + +- `title` (String) The name of this property + + ### Nested Schema for `relations` @@ -75,8 +108,7 @@ Required: Optional: - `identifier` (String) The identifier of the relation -- `many` (Boolean) Unsupported ATM. -Whether or not the relation is many +- `many` (Boolean) Whether or not the relation is many - `required` (Boolean) Whether or not the relation is required diff --git a/go.mod b/go.mod index 6ed121e6..2f21b91d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-docs v0.13.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0 ) require ( @@ -21,7 +21,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect @@ -31,11 +31,11 @@ require ( github.com/hashicorp/go-plugin v1.4.4 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/hcl/v2 v2.13.0 // indirect + github.com/hashicorp/hcl/v2 v2.14.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.17.2 // indirect + github.com/hashicorp/terraform-exec v0.17.3 // indirect github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-go v0.12.0 // indirect + github.com/hashicorp/terraform-plugin-go v0.14.0 // indirect github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect @@ -53,18 +53,20 @@ require ( github.com/oklog/run v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/russross/blackfriday v1.6.0 // indirect + github.com/samber/lo v1.32.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.10.0 // indirect + github.com/zclconf/go-cty v1.11.0 // indirect golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect + golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/appengine v1.6.6 // indirect google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect google.golang.org/grpc v1.48.0 // indirect - google.golang.org/protobuf v1.28.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect ) diff --git a/go.sum b/go.sum index 898610cc..8ebbafbd 100644 --- a/go.sum +++ b/go.sum @@ -98,6 +98,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -132,20 +134,28 @@ github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH9 github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= +github.com/hashicorp/hcl/v2 v2.14.0 h1:jX6+Q38Ly9zaAJlAjnFVyeNSNCKKW8D0wvyg7vij5Wc= +github.com/hashicorp/hcl/v2 v2.14.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go= github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8= +github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= +github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= github.com/hashicorp/terraform-plugin-go v0.12.0 h1:6wW9mT1dSs0Xq4LR6HXj1heQ5ovr5GxXNJwkErZzpJw= github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M= +github.com/hashicorp/terraform-plugin-go v0.14.0 h1:ttnSlS8bz3ZPYbMb84DpcPhY4F5DsQtcAS7cHo8uvP4= +github.com/hashicorp/terraform-plugin-go v0.14.0/go.mod h1:2nNCBeRLaenyQEi78xrGrs9hMbulveqG/zDMQSvVJTE= github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0 h1:+KxZULPsbjpAVoP0WNj/8aVW6EqpcX5JcUcQ5wl7Da4= github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0/go.mod h1:DwGJG3KNxIPluVk6hexvDfYR/MS/eKGpiztJoT3Bbbw= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0 h1:D4EeQm0piYXIHp6ZH3zjyP2Elq6voC64x3GZptaiefA= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0/go.mod h1:xkJGavPvP9kYS/VbiW8o7JuTNgPwm7Tiw/Ie/b46r4c= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= @@ -216,6 +226,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= +github.com/samber/lo v1.32.0 h1:MjbngaDxbQ+ockKTEoF0IQtW2lX1VgqZ5IBhxi4fmTU= +github.com/samber/lo v1.32.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8= github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= @@ -236,6 +248,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -249,6 +262,8 @@ github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLE github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.11.0 h1:726SxLdi2SDnjY+BStqB9J1hNp4+2WlzyXLuimibIe0= +github.com/zclconf/go-cty v1.11.0/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -262,6 +277,8 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= +golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -362,6 +379,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/port/cli/models.go b/port/cli/models.go index 20f11a3f..c9fcfacf 100644 --- a/port/cli/models.go +++ b/port/cli/models.go @@ -29,13 +29,29 @@ type ( } BlueprintProperty struct { - Type string `json:"type,omitempty"` - Title string `json:"title,omitempty"` - Identifier string `json:"identifier,omitempty"` - Default string `json:"default,omitempty"` - Format string `json:"format,omitempty"` - Description string `json:"description,omitempty"` - Pattern string `json:"pattern,omitempty"` + Type string `json:"type,omitempty"` + Title string `json:"title,omitempty"` + Identifier string `json:"identifier,omitempty"` + Default string `json:"default,omitempty"` + Icon string `json:"icon,omitempty"` + Format string `json:"format,omitempty"` + Description string `json:"description,omitempty"` + Blueprint string `json:"blueprint,omitempty"` + Pattern string `json:"pattern,omitempty"` + Enum []string `json:"enum,omitempty"` + EnumColors map[string]string `json:"enumColors,omitempty"` + } + + BlueprintMirrorProperty struct { + Identifier string `json:"identifier,omitempty"` + Title string `json:"title,omitempty"` + Path string `json:"path,omitempty"` + } + + BlueprintFormulaProperty struct { + Identifier string `json:"identifier,omitempty"` + Title string `json:"title,omitempty"` + Formula string `json:"formula,omitempty"` } BlueprintSchema struct { @@ -57,12 +73,15 @@ type ( Blueprint struct { Meta - Identifier string `json:"identifier,omitempty"` - Title string `json:"title"` - Icon string `json:"icon"` - Schema BlueprintSchema `json:"schema"` - ChangelogDestination *ChangelogDestination `json:"changelogDestination,omitempty"` - Relations map[string]Relation `json:"relations"` + Identifier string `json:"identifier,omitempty"` + Title string `json:"title"` + Icon string `json:"icon"` + Description string `json:"description"` + Schema BlueprintSchema `json:"schema"` + FormulaProperties map[string]BlueprintFormulaProperty `json:"formulaProperties"` + MirrorProperties map[string]BlueprintMirrorProperty `json:"mirrorProperties"` + ChangelogDestination *ChangelogDestination `json:"changelogDestination,omitempty"` + Relations map[string]Relation `json:"relations"` } Action struct { diff --git a/port/resource_port_action.go b/port/resource_port_action.go index 69feaca2..9ca0e6b6 100644 --- a/port/resource_port_action.go +++ b/port/resource_port_action.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/port-labs/terraform-provider-port-labs/port/cli" + "github.com/samber/lo" ) func newActionResource() *schema.Resource { @@ -78,23 +79,33 @@ func newActionResource() *schema.Resource { Optional: true, Description: "A specific data format to pair with some of the available types", }, + "blueprint": { + Type: schema.TypeString, + Optional: true, + Description: "When selecting format 'entity', the identifier of the target blueprint", + }, "pattern": { Type: schema.TypeString, Optional: true, Description: "A regular expression (regex) pattern to specify the set of allowed values for the property", }, + "required": { + Type: schema.TypeBool, + Optional: true, + Description: "Whether the property is required or not", + }, + "enum": { + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Type: schema.TypeList, + Optional: true, + Description: "A list of allowed values for the property", + }, }, }, Optional: true, }, - "required_properties": { - Description: "The required properties of the action", - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, "invocation_method": { Type: schema.TypeList, MinItems: 1, @@ -147,6 +158,7 @@ func writeActionFieldsToResource(d *schema.ResourceData, action *cli.Action) { "type": action.InvocationMethod.Type, "url": action.InvocationMethod.Url, }}) + d.Set("trigger", action.Trigger) properties := schema.Set{F: func(i interface{}) int { id := (i.(map[string]interface{}))["identifier"].(string) @@ -161,6 +173,13 @@ func writeActionFieldsToResource(d *schema.ResourceData, action *cli.Action) { p["default"] = v.Default p["format"] = v.Format p["pattern"] = v.Pattern + p["blueprint"] = v.Blueprint + p["enum"] = v.Enum + if lo.Contains(action.UserInputs.Required, k) { + p["required"] = true + } else { + p["required"] = false + } properties.Add(p) } d.Set("user_properties", &properties) @@ -187,6 +206,8 @@ func actionResourceToBody(d *schema.ResourceData) (*cli.Action, error) { props := d.Get("user_properties").(*schema.Set) properties := make(map[string]cli.BlueprintProperty, props.Len()) + var required []string + for _, prop := range props.List() { p := prop.(map[string]interface{}) propFields := cli.BlueprintProperty{} @@ -205,18 +226,21 @@ func actionResourceToBody(d *schema.ResourceData) (*cli.Action, error) { if f, ok := p["format"]; ok && f != "" { propFields.Format = f.(string) } + if b, ok := p["blueprint"]; ok && b != "" { + propFields.Blueprint = b.(string) + } if p, ok := p["pattern"]; ok && p != "" { propFields.Pattern = p.(string) } - properties[p["identifier"].(string)] = propFields - } - var required []string - if rp, ok := d.GetOk("required"); ok { - requiredProps := rp.(*schema.Set) - required = make([]string, requiredProps.Len()) - for _, p := range requiredProps.List() { - required = append(required, p.(string)) + if r, ok := p["required"]; ok && r.(bool) { + required = append(required, p["identifier"].(string)) } + if e, ok := p["enum"]; ok && e != nil { + for _, v := range e.([]interface{}) { + propFields.Enum = append(propFields.Enum, v.(string)) + } + } + properties[p["identifier"].(string)] = propFields } action.UserInputs = cli.ActionUserInputs{Properties: properties, Required: required} diff --git a/port/resource_port_action_test.go b/port/resource_port_action_test.go index f97c1539..1fd6479d 100644 --- a/port/resource_port_action_test.go +++ b/port/resource_port_action_test.go @@ -12,7 +12,6 @@ func TestAccPortAction(t *testing.T) { identifier := genID() actionIdentifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF test microservice" icon = "Terraform" @@ -40,7 +39,6 @@ func TestAccPortAction(t *testing.T) { } `, identifier, actionIdentifier) testAccActionConfigUpdate := fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF test microservice" icon = "Terraform" @@ -63,7 +61,9 @@ func TestAccPortAction(t *testing.T) { user_properties { identifier = "clear_cache" type = "string" + required = true title = "Clear cache" + enum = ["yes", "no"] } user_properties { identifier = "submit_report" @@ -106,6 +106,8 @@ func TestAccPortAction(t *testing.T) { resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.identifier", "clear_cache"), resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.type", "string"), resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.title", "Clear cache"), + resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.enum.0", "yes"), + resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.required", "true"), resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.1.identifier", "submit_report"), resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.1.type", "boolean"), resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.1.title", "Submit report"), @@ -119,7 +121,6 @@ func TestAccPortActionPropMeta(t *testing.T) { identifier := genID() actionIdentifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF test microservice" icon = "Terraform" @@ -179,11 +180,60 @@ func TestAccPortActionPropMeta(t *testing.T) { }) } -func TestAccPortActionWebhhokInvocation(t *testing.T) { +func TestAccPortActionWebhookInvocation(t *testing.T) { + identifier := genID() + actionIdentifier := genID() + var testAccActionConfigCreate = fmt.Sprintf(` + resource "port-labs_blueprint" "microservice" { + title = "TF test microservice" + icon = "Terraform" + identifier = "%s" + properties { + identifier = "text" + type = "string" + title = "text" + } + } + resource "port-labs_action" "restart_microservice" { + title = "Restart service" + icon = "Terraform" + identifier = "%s" + blueprint_identifier = port-labs_blueprint.microservice.identifier + trigger = "DAY-2" + user_properties { + identifier = "multiselect" + type = "string" + title = "multiselect" + description = "multiselect" + format = "entity" + blueprint = port-labs_blueprint.microservice.identifier + } + invocation_method { + type = "KAFKA" + } + } +`, identifier, actionIdentifier) + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "port-labs": Provider(), + }, + Steps: []resource.TestStep{ + { + Config: testAccActionConfigCreate, + Destroy: false, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.blueprint", identifier), + resource.TestCheckResourceAttr("port-labs_action.restart_microservice", "user_properties.0.format", "entity"), + ), + }, + }, + }) +} + +func TestAccPortActionEntityMultiselect(t *testing.T) { identifier := genID() actionIdentifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF test microservice" icon = "Terraform" diff --git a/port/resource_port_blueprint.go b/port/resource_port_blueprint.go index 996987ef..3e2978c0 100644 --- a/port/resource_port_blueprint.go +++ b/port/resource_port_blueprint.go @@ -3,11 +3,11 @@ package port import ( "context" - "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/port-labs/terraform-provider-port-labs/port/cli" + "github.com/samber/lo" ) var ICONS = []string{"Actions", "Airflow", "Ansible", "Argo", "AuditLog", "Aws", "Azure", "Blueprint", "Bucket", "Cloud", "Cluster", "CPU", "Customer", "Datadog", "Day2Operation", "DefaultEntity", "DefaultProperty", "DeployedAt", "Deployment", "DevopsTool", "Docs", "Environment", "Git", "Github", "GitVersion", "GoogleCloud", "GPU", "Grafana", "Infinity", "Jenkins", "Lambda", "Link", "Lock", "Microservice", "Moon", "Node", "Okta", "Package", "Permission", "Relic", "Server", "Service", "Team", "Terraform", "User"} @@ -43,6 +43,11 @@ func newBlueprintResource() *schema.Resource { ValidateFunc: validation.StringInSlice(ICONS, false), Required: true, }, + "description": { + Type: schema.TypeString, + Description: "The description of the blueprint", + Optional: true, + }, "relations": { Description: "The blueprints that are connected to this blueprint", Type: schema.TypeSet, @@ -69,15 +74,9 @@ func newBlueprintResource() *schema.Resource { Description: "Whether or not the relation is required", }, "many": { - Type: schema.TypeBool, - Optional: true, - ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics { - if i.(bool) { - return diag.Errorf("Many relations are not supported") - } - return nil - }, - Description: "Unsupported ATM.\nWhether or not the relation is many", + Type: schema.TypeBool, + Optional: true, + Description: "Whether or not the relation is many", }, }, }, @@ -93,6 +92,12 @@ func newBlueprintResource() *schema.Resource { Required: true, Description: "The identifier of the property", }, + "icon": { + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice(ICONS, false), + Optional: true, + Description: "The icon of the property", + }, "title": { Type: schema.TypeString, Required: true, @@ -118,10 +123,79 @@ func newBlueprintResource() *schema.Resource { Optional: true, Description: "The format of the Property", }, + "enum": { + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Type: schema.TypeList, + Optional: true, + Description: "A list of allowed values for the property", + }, + "enum_colors": { + Type: schema.TypeMap, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "A map of colors for the enum values", + }, + "required": { + Type: schema.TypeBool, + Optional: true, + Description: "Whether or not the property is required", + }, }, }, Required: true, }, + "mirror_properties": { + Type: schema.TypeSet, + Description: "When two Blueprints are connected via a Relation, a new set of properties becomes available to Entities in the source Blueprint.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "identifier": { + Type: schema.TypeString, + Required: true, + Description: "The identifier of the property", + }, + "title": { + Type: schema.TypeString, + Optional: true, + Description: "The name of this property", + }, + "path": { + Type: schema.TypeString, + Required: true, + Description: "The path of the realtions towards the property", + }, + }, + }, + Optional: true, + }, + "formula_properties": { + Type: schema.TypeSet, + Description: "A property that is calculated by a formula", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "identifier": { + Type: schema.TypeString, + Required: true, + Description: "The identifier of the property", + }, + "title": { + Type: schema.TypeString, + Optional: true, + Description: "The name of this property", + }, + "formula": { + Type: schema.TypeString, + Required: true, + Description: "The path of the realtions towards the property", + }, + }, + }, + Optional: true, + }, "changelog_destination": { Type: schema.TypeList, MinItems: 1, @@ -180,6 +254,7 @@ func writeBlueprintFieldsToResource(d *schema.ResourceData, b *cli.Blueprint) { d.SetId(b.Identifier) d.Set("title", b.Title) d.Set("icon", b.Icon) + d.Set("description", b.Description) d.Set("created_at", b.CreatedAt.String()) d.Set("created_by", b.CreatedBy) d.Set("updated_at", b.UpdatedAt.String()) @@ -194,6 +269,14 @@ func writeBlueprintFieldsToResource(d *schema.ResourceData, b *cli.Blueprint) { id := (i.(map[string]interface{}))["identifier"].(string) return schema.HashString(id) }} + formula_properties := schema.Set{F: func(i interface{}) int { + id := (i.(map[string]interface{}))["identifier"].(string) + return schema.HashString(id) + }} + mirror_properties := schema.Set{F: func(i interface{}) int { + id := (i.(map[string]interface{}))["identifier"].(string) + return schema.HashString(id) + }} for k, v := range b.Schema.Properties { p := map[string]interface{}{} p["identifier"] = k @@ -202,9 +285,36 @@ func writeBlueprintFieldsToResource(d *schema.ResourceData, b *cli.Blueprint) { p["description"] = v.Description p["default"] = v.Default p["format"] = v.Format + p["icon"] = v.Icon + p["enum"] = v.Enum + p["enum_colors"] = v.EnumColors + if lo.Contains(b.Schema.Required, k) { + p["required"] = true + } else { + p["required"] = false + } properties.Add(p) } + + for k, v := range b.MirrorProperties { + p := map[string]interface{}{} + p["identifier"] = k + p["title"] = v.Title + p["path"] = v.Path + mirror_properties.Add(p) + } + + for k, v := range b.FormulaProperties { + p := map[string]interface{}{} + p["identifier"] = k + p["title"] = v.Title + p["formula"] = v.Formula + formula_properties.Add(p) + } + d.Set("properties", &properties) + d.Set("mirror_properties", &mirror_properties) + d.Set("formula_properties", &formula_properties) } func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) { @@ -219,7 +329,10 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) { b.Title = d.Get("title").(string) b.Icon = d.Get("icon").(string) + b.Description = d.Get("description").(string) props := d.Get("properties").(*schema.Set) + mirror_props := d.Get("mirror_properties").(*schema.Set) + formula_props := d.Get("formula_properties").(*schema.Set) if changelogDestination, ok := d.GetOk("changelog_destination"); ok { if b.ChangelogDestination == nil { @@ -230,6 +343,7 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) { } properties := make(map[string]cli.BlueprintProperty, props.Len()) + var required []string for _, prop := range props.List() { p := prop.(map[string]interface{}) propFields := cli.BlueprintProperty{} @@ -248,7 +362,54 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) { if f, ok := p["format"]; ok && f != "" { propFields.Format = f.(string) } - properties[p["identifier"].(string)] = propFields + if i, ok := p["icon"]; ok && i != "" { + propFields.Icon = i.(string) + } + if r, ok := p["required"]; ok && r.(bool) { + required = append(required, p["identifier"].(string)) + } + if e, ok := p["enum"]; ok && e != nil { + for _, v := range e.([]interface{}) { + propFields.Enum = append(propFields.Enum, v.(string)) + } + } + if e, ok := p["enum_colors"]; ok && e != nil { + enumColors := make(map[string]string) + for key, value := range e.(map[string]interface{}) { + enumColors[key] = value.(string) + } + propFields.EnumColors = enumColors + } + // TODO: remove the if statement when this issues is solved, https://github.com/hashicorp/terraform-plugin-sdk/pull/1042/files + if p["identifier"] != "" { + properties[p["identifier"].(string)] = propFields + } + } + + mirror_properties := make(map[string]cli.BlueprintMirrorProperty, mirror_props.Len()) + for _, prop := range mirror_props.List() { + p := prop.(map[string]interface{}) + propFields := cli.BlueprintMirrorProperty{} + if t, ok := p["title"]; ok && t != "" { + propFields.Title = t.(string) + } + if p, ok := p["path"]; ok && p != "" { + propFields.Path = p.(string) + } + mirror_properties[p["identifier"].(string)] = propFields + } + + formula_properties := make(map[string]cli.BlueprintFormulaProperty, formula_props.Len()) + for _, prop := range formula_props.List() { + p := prop.(map[string]interface{}) + propFields := cli.BlueprintFormulaProperty{} + if t, ok := p["title"]; ok && t != "" { + propFields.Title = t.(string) + } + if f, ok := p["formula"]; ok && f != "" { + propFields.Formula = f.(string) + } + formula_properties[p["identifier"].(string)] = propFields } rels := d.Get("relations").(*schema.Set) @@ -272,8 +433,10 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) { relations[p["identifier"].(string)] = relationFields } - b.Schema = cli.BlueprintSchema{Properties: properties} + b.Schema = cli.BlueprintSchema{Properties: properties, Required: required} b.Relations = relations + b.FormulaProperties = formula_properties + b.MirrorProperties = mirror_properties return b, nil } diff --git a/port/resource_port_blueprint_test.go b/port/resource_port_blueprint_test.go index bbc70510..a2ebcca3 100644 --- a/port/resource_port_blueprint_test.go +++ b/port/resource_port_blueprint_test.go @@ -20,16 +20,10 @@ func genID() string { func TestAccPortBlueprint(t *testing.T) { identifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF Provider Test BP0" icon = "Terraform" identifier = "%s" - properties { - identifier = "text" - type = "string" - title = "text" - } properties { identifier = "bool" type = "boolean" @@ -50,6 +44,17 @@ func TestAccPortBlueprint(t *testing.T) { type = "array" title = "array" } + properties { + identifier = "text" + type = "string" + title = "text" + icon = "Terraform" + enum = ["a", "b", "c"] + enum_colors = { + a = "red" + b = "blue" + } + } } `, identifier) resource.Test(t, resource.TestCase{ @@ -59,6 +64,11 @@ func TestAccPortBlueprint(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccActionConfigCreate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.identifier", "text"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.enum.0", "a"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.enum_colors.a", "red"), + ), }, }, }) @@ -67,7 +77,6 @@ func TestAccPortBlueprint(t *testing.T) { func TestAccBlueprintWithChangelogDestination(t *testing.T) { identifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF Provider Test BP0" icon = "Terraform" @@ -103,7 +112,6 @@ func TestAccPortBlueprintWithRelation(t *testing.T) { identifier1 := genID() identifier2 := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice1" { title = "TF Provider Test BP2" icon = "Terraform" @@ -145,25 +153,36 @@ func TestAccPortBlueprintWithRelation(t *testing.T) { func TestAccPortBlueprintUpdate(t *testing.T) { identifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice1" { + description = "Test Description" title = "TF Provider Test BP2" icon = "Terraform" identifier = "%s" properties { + required = true identifier = "text" type = "string" + icon = "Terraform" title = "text" + enum = ["a", "b", "c"] + enum_colors = { + a = "red" + b = "blue" + } + } + formula_properties { + identifier = "formula_id" + formula = "{{$identifier}}formula" } } `, identifier) var testAccActionConfigUpdate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice1" { title = "TF Provider Test BP2" icon = "Terraform" identifier = "%s" properties { + required = false identifier = "text" type = "string" title = "text" @@ -173,10 +192,13 @@ func TestAccPortBlueprintUpdate(t *testing.T) { type = "number" title = "num" } + formula_properties { + identifier = "formula_id" + formula = "{{$identifier}}formula-updated" + } } `, identifier) var testAccActionConfigUpdateAgain = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice1" { title = "TF Provider Test BP2" icon = "Terraform" @@ -196,14 +218,21 @@ func TestAccPortBlueprintUpdate(t *testing.T) { { Config: testAccActionConfigCreate, Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "description", "Test Description"), resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "properties.0.title", "text"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "properties.0.required", "true"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "properties.0.icon", "Terraform"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "formula_properties.0.formula", "{{$identifier}}formula"), ), }, { Config: testAccActionConfigUpdate, Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "description", ""), resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "properties.0.title", "num"), resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "properties.1.title", "text"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "properties.1.required", "false"), + resource.TestCheckResourceAttr("port-labs_blueprint.microservice1", "formula_properties.0.formula", "{{$identifier}}formula-updated"), ), }, { @@ -221,7 +250,6 @@ func TestAccPortBlueprintUpdateRelation(t *testing.T) { envID := genID() vmID := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "Environment" { title = "Environment" icon = "Environment" @@ -249,7 +277,6 @@ func TestAccPortBlueprintUpdateRelation(t *testing.T) { } `, envID, vmID) var testAccActionConfigUpdate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "Environment" { title = "Environment" icon = "Environment" @@ -302,3 +329,142 @@ func TestAccPortBlueprintUpdateRelation(t *testing.T) { }, }) } + +func TestAccPortBlueprintWithMirrorProperty(t *testing.T) { + identifier1 := genID() + identifier2 := genID() + var testAccActionConfigCreate = fmt.Sprintf(` + resource "port-labs_blueprint" "microservice1" { + title = "TF Provider Test BP2" + icon = "Terraform" + identifier = "%s" + properties { + identifier = "text" + type = "string" + title = "text" + } + } + resource "port-labs_blueprint" "microservice2" { + title = "TF Provider Test BP3" + icon = "Terraform" + identifier = "%s" + properties { + identifier = "text" + type = "string" + title = "text" + } + mirror_properties { + identifier = "mirror-for-microservice1" + title = "Mirror for microservice1" + path = "test-rel.$identifier" + } + relations { + identifier = "test-rel" + title = "Test Relation" + target = port-labs_blueprint.microservice1.identifier + } + } +`, identifier1, identifier2) + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "port-labs": Provider(), + }, + Steps: []resource.TestStep{ + { + Config: testAccActionConfigCreate, + }, + }, + }) +} + +func TestAccPortBlueprintUpdateMirrorProperty(t *testing.T) { + envID := genID() + vmID := genID() + var testAccActionConfigCreate = fmt.Sprintf(` + resource "port-labs_blueprint" "Environment" { + title = "Environment" + icon = "Environment" + identifier = "%s" + properties { + identifier = "env_name" + type = "string" + title = "Name" + } + } + resource "port-labs_blueprint" "vm" { + title = "Virtual Machine" + icon = "Azure" + identifier = "%s" + properties { + identifier = "image" + type = "string" + title = "Image" + } + mirror_properties { + identifier = "mirror-for-environment" + title = "Mirror for environment" + path = "vm-to-environment.$identifier" + } + relations { + identifier = "vm-to-environment" + title = "Related Environment" + target = port-labs_blueprint.Environment.identifier + } + } +`, envID, vmID) + var testAccActionConfigUpdate = fmt.Sprintf(` + resource "port-labs_blueprint" "Environment" { + title = "Environment" + icon = "Environment" + identifier = "%s" + properties { + identifier = "env_name" + type = "string" + title = "Name" + } + } + resource "port-labs_blueprint" "vm" { + title = "Virtual Machine" + icon = "Azure" + identifier = "%s" + properties { + identifier = "image" + type = "string" + title = "Image" + } + mirror_properties { + identifier = "mirror-for-environment" + title = "Mirror for environment2" + path = "environment.$identifier" + } + relations { + identifier = "environment" + title = "Related Environment" + target = port-labs_blueprint.Environment.identifier + } + } +`, envID, vmID) + resource.Test(t, resource.TestCase{ + Providers: map[string]*schema.Provider{ + "port-labs": Provider(), + }, + Steps: []resource.TestStep{ + { + Config: testAccActionConfigCreate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port-labs_blueprint.vm", "mirror_properties.#", "1"), + resource.TestCheckResourceAttr("port-labs_blueprint.vm", "mirror_properties.0.title", "Mirror for environment"), + resource.TestCheckResourceAttr("port-labs_blueprint.vm", "mirror_properties.0.identifier", "mirror-for-environment"), + ), + }, + { + Config: testAccActionConfigUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port-labs_blueprint.vm", "mirror_properties.#", "1"), + resource.TestCheckResourceAttr("port-labs_blueprint.vm", "mirror_properties.0.title", "Mirror for environment2"), + resource.TestCheckResourceAttr("port-labs_blueprint.vm", "mirror_properties.0.identifier", "mirror-for-environment"), + ), + }, + }, + }) +} diff --git a/port/resource_port_entity_test.go b/port/resource_port_entity_test.go index 39424169..2a86d4c9 100644 --- a/port/resource_port_entity_test.go +++ b/port/resource_port_entity_test.go @@ -11,7 +11,6 @@ import ( func TestAccPortEntityUpdateProp(t *testing.T) { identifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "tf_bp" { title = "TF Provider Test" icon = "Terraform" @@ -33,7 +32,6 @@ func TestAccPortEntityUpdateProp(t *testing.T) { } `, identifier) var testAccActionConfigUpdate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "tf_bp" { title = "TF Provider Test" icon = "Terraform" @@ -86,7 +84,6 @@ func TestAccPortEntityUpdateProp(t *testing.T) { func TestAccPortEntity(t *testing.T) { identifier := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF Provider Test BP0" icon = "Terraform" @@ -119,7 +116,7 @@ func TestAccPortEntity(t *testing.T) { } resource "port-labs_entity" "microservice" { title = "monolith" - blueprint = "tf-provider-test-bp" + blueprint = "${port-labs_blueprint.microservice.identifier}" properties { name = "text" value = "hedwig" @@ -158,7 +155,6 @@ func TestAccPortEntitiesRelation(t *testing.T) { identifier1 := genID() identifier2 := genID() var testAccActionConfigCreate = fmt.Sprintf(` - provider "port-labs" {} resource "port-labs_blueprint" "microservice" { title = "TF Provider Test BP0" icon = "Terraform"