Skip to content

Commit debd295

Browse files
authored
Merge pull request #34 from port-labs/PORT-3431-terraform-provider-add-support-for-items-in-array-property
Add support for blueprint items in array property
2 parents 4e8d5d3 + 7604044 commit debd295

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

docs/resources/action.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Port action
1919

2020
- `blueprint_identifier` (String) The identifier of the blueprint
2121
- `identifier` (String) The identifier of the action
22-
- `invocation_method` (Block List, Min: 1, Max: 1) The methods the action is dispatched in. Supports WEBHOOK, KAFKA and GITHUB (see [below for nested schema](#nestedblock--invocation_method))
22+
- `invocation_method` (Block List, Min: 1, Max: 1) The methods the action is dispatched in. Supports WEBHOOK, KAFKA, GITHUB and AZURE-DEVOPS (see [below for nested schema](#nestedblock--invocation_method))
2323
- `title` (String) The display name of the action
2424
- `trigger` (String) The type of the action, one of CREATE, DAY-2, DELETE
2525

@@ -43,12 +43,14 @@ Required:
4343
Optional:
4444

4545
- `agent` (Boolean) Relevant only when selecting type WEBHOOK. The flag that controls if the port execution agent will handle the action
46+
- `azure_org` (String) Required when selecting type AZURE-DEVOPS. The Azure Devops org that the webhook belongs to
4647
- `omit_payload` (Boolean) Relevant only when selecting type GITHUB. The flag that controls if to omit Port's payload from workflow's dispatch input
4748
- `omit_user_inputs` (Boolean) Relevant only when selecting type GITHUB. The flag that controls if to omit user inputs from workflow's dispatch input
4849
- `org` (String) Required when selecting type GITHUB. The GitHub org that the workflow belongs to
4950
- `repo` (String) Required when selecting type GITHUB. The GitHub repository that the workflow belongs to
5051
- `report_workflow_status` (Boolean) Relevant only when selecting type GITHUB. The flag that controls if to report the action status when the workflow completes
5152
- `url` (String) Required when selecting type WEBHOOK. The URL to which the action is dispatched
53+
- `webhook` (String) Required when selecting type AZURE-DEVOPS. The Azure Devops webhook id
5254
- `workflow` (String) Required when selecting type GITHUB. The GitHub workflow id or the workflow file name
5355

5456

docs/resources/blueprint.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Port blueprint
2323

2424
### Optional
2525

26-
- `calculation_properties` (Block Set) A set of properties that are calculated upon Entitys regular properties. (see [below for nested schema](#nestedblock--calculation_properties))
26+
- `calculation_properties` (Block Set) A set of properties that are calculated upon entity's regular properties. (see [below for nested schema](#nestedblock--calculation_properties))
2727
- `changelog_destination` (Block List, Max: 1) Blueprints changelog destination, Supports WEBHOOK and KAFKA (see [below for nested schema](#nestedblock--changelog_destination))
2828
- `data_source` (String, Deprecated) The data source for entities of this blueprint
2929
- `description` (String) The description of the blueprint
@@ -57,6 +57,7 @@ Optional:
5757
- `enum_colors` (Map of String) A map of colors for the enum values
5858
- `format` (String) The format of the Property
5959
- `icon` (String) The icon of the property
60+
- `items` (Map of String) A metadata of an array's items, in case the type is an array
6061
- `required` (Boolean) Whether or not the property is required
6162
- `spec` (String) The specification of the property, one of "async-api", "open-api", "embedded-url"
6263

port/cli/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (c *PortClient) Authenticate(ctx context.Context, clientID, clientSecret st
4545
url := "v1/auth/access_token"
4646
resp, err := c.Client.R().
4747
SetBody(map[string]interface{}{
48-
"clientId": clientID,
48+
"clientId": clientID,
4949
"clientSecret": clientSecret,
5050
}).
5151
SetContext(ctx).

port/cli/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type (
3232
Type string `json:"type,omitempty"`
3333
Title string `json:"title,omitempty"`
3434
Identifier string `json:"identifier,omitempty"`
35+
Items map[string]any `json:"items,omitempty"`
3536
Default interface{} `json:"default,omitempty"`
3637
Icon string `json:"icon,omitempty"`
3738
Format string `json:"format,omitempty"`

port/resource_port_blueprint.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ func newBlueprintResource() *schema.Resource {
106106
Required: true,
107107
Description: "The type of the property",
108108
},
109+
"items": {
110+
Type: schema.TypeMap,
111+
Optional: true,
112+
Description: "A metadata of an array's items, in case the type is an array",
113+
},
109114
"description": {
110115
Type: schema.TypeString,
111116
Optional: true,
@@ -186,7 +191,7 @@ func newBlueprintResource() *schema.Resource {
186191
},
187192
"calculation_properties": {
188193
Type: schema.TypeSet,
189-
Description: "A set of properties that are calculated upon Entitys regular properties.",
194+
Description: "A set of properties that are calculated upon entity's regular properties.",
190195
Elem: &schema.Resource{
191196
Schema: map[string]*schema.Schema{
192197
"identifier": {
@@ -329,6 +334,7 @@ func writeBlueprintFieldsToResource(d *schema.ResourceData, b *cli.Blueprint) {
329334
p["identifier"] = k
330335
p["title"] = v.Title
331336
p["type"] = v.Type
337+
p["items"] = v.Items
332338
p["description"] = v.Description
333339
p["format"] = v.Format
334340
p["icon"] = v.Icon
@@ -456,6 +462,13 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) {
456462
if d, ok := p["default_items"]; ok && d != nil {
457463
propFields.Default = d
458464
}
465+
if i, ok := p["items"]; ok && i != nil {
466+
items := make(map[string]any)
467+
for key, value := range i.(map[string]any) {
468+
items[key] = value.(string)
469+
}
470+
propFields.Items = items
471+
}
459472
case "object":
460473
if d, ok := p["default"]; ok && d.(string) != "" {
461474
defaultObj := make(map[string]interface{})

port/resource_port_blueprint_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ func TestAccPortBlueprint(t *testing.T) {
4545
properties {
4646
identifier = "array"
4747
type = "array"
48+
items = {
49+
type = "string"
50+
format = "url"
51+
}
4852
title = "array"
49-
default_items = [1, 2, 3]
53+
default_items = ["https://getport.io", "https://app.getport.io"]
5054
}
5155
properties {
5256
identifier = "text"
@@ -70,8 +74,10 @@ func TestAccPortBlueprint(t *testing.T) {
7074
{
7175
Config: testAccActionConfigCreate,
7276
Check: resource.ComposeTestCheckFunc(
73-
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.default_items.0", "1"),
74-
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.default_items.#", "3"),
77+
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.default_items.0", "https://getport.io"),
78+
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.default_items.#", "2"),
79+
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.items.type", "string"),
80+
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.items.format", "url"),
7581
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.1.default", "1"),
7682
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.2.identifier", "text"),
7783
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.2.enum.0", "a"),

0 commit comments

Comments
 (0)