Skip to content

Commit

Permalink
Add agent in change log destination (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirsegev authored May 21, 2023
1 parent 221c94f commit 27985fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/resources/blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Required:

Optional:

- `agent` (Boolean) Required when selecting type WEBHOOK. Defines whether to use Port Agent for execution or not.
- `url` (String) Required when selecting type WEBHOOK. The URL to which the changelog is dispatched

<a id="nestedblock--mirror_properties"></a>
Expand Down
5 changes: 3 additions & 2 deletions port/cli/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ type (
}

ChangelogDestination struct {
Type string `json:"type,omitempty"`
Url string `json:"url,omitempty"`
Type string `json:"type,omitempty"`
Url string `json:"url,omitempty"`
Agent bool `json:"agent,omitempty"`
}

ActionUserInputs = BlueprintSchema
Expand Down
11 changes: 9 additions & 2 deletions port/resource_port_blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ func newBlueprintResource() *schema.Resource {
Optional: true,
Description: "Required when selecting type WEBHOOK. The URL to which the changelog is dispatched",
},
"agent": {
Type: schema.TypeBool,
Optional: true,
Description: "Required when selecting type WEBHOOK. Defines whether to use Port Agent for execution or not.",
},
},
},
Optional: true,
Expand Down Expand Up @@ -424,8 +429,9 @@ func writeBlueprintFieldsToResource(d *schema.ResourceData, b *cli.Blueprint) {
d.Set("updated_by", b.UpdatedBy)
if b.ChangelogDestination != nil {
d.Set("changelog_destination", []any{map[string]any{
"type": b.ChangelogDestination.Type,
"url": b.ChangelogDestination.Url,
"type": b.ChangelogDestination.Type,
"url": b.ChangelogDestination.Url,
"agent": b.ChangelogDestination.Agent,
}})
}
properties := schema.Set{F: func(i interface{}) int {
Expand Down Expand Up @@ -590,6 +596,7 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) {
}
b.ChangelogDestination.Type = changelogDestination.([]any)[0].(map[string]interface{})["type"].(string)
b.ChangelogDestination.Url = changelogDestination.([]any)[0].(map[string]interface{})["url"].(string)
b.ChangelogDestination.Agent = changelogDestination.([]any)[0].(map[string]interface{})["agent"].(bool)
}

properties := make(map[string]cli.BlueprintProperty, props.Len())
Expand Down
2 changes: 2 additions & 0 deletions port/resource_port_blueprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ func TestAccBlueprintWithChangelogDestination(t *testing.T) {
changelog_destination {
type = "WEBHOOK"
url = "https://google.com"
agent = true
}
}
`, identifier)
Expand All @@ -324,6 +325,7 @@ func TestAccBlueprintWithChangelogDestination(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "changelog_destination.0.type", "WEBHOOK"),
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "changelog_destination.0.url", "https://google.com"),
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "changelog_destination.0.agent", "true"),
),
},
},
Expand Down

0 comments on commit 27985fd

Please sign in to comment.