diff --git a/internal/cli/models.go b/internal/cli/models.go index 7da6d33a..f459e717 100644 --- a/internal/cli/models.go +++ b/internal/cli/models.go @@ -205,6 +205,8 @@ type ( Enabled *bool `json:"enabled,omitempty"` Security *Security `json:"security,omitempty"` Mappings []Mappings `json:"mappings,omitempty"` + WebhookKey string `json:"webhookKey,omitempty"` + Url string `json:"url,omitempty"` } Security struct { diff --git a/port/webhook/model.go b/port/webhook/model.go index 033d432a..758fd824 100644 --- a/port/webhook/model.go +++ b/port/webhook/model.go @@ -35,6 +35,8 @@ type WebhookModel struct { Title types.String `tfsdk:"title"` Description types.String `tfsdk:"description"` Enabled types.Bool `tfsdk:"enabled"` + WebhookKey types.String `tfsdk:"webhook_key"` + Url types.String `tfsdk:"url"` Security *SecurityModel `tfsdk:"security"` Mappings []MappingsModel `tfsdk:"mappings"` CreatedAt types.String `tfsdk:"created_at"` diff --git a/port/webhook/refreshWebhookState.go b/port/webhook/refreshWebhookState.go index d7e5b9c6..0e820471 100644 --- a/port/webhook/refreshWebhookState.go +++ b/port/webhook/refreshWebhookState.go @@ -15,6 +15,8 @@ func refreshWebhookState(ctx context.Context, state *WebhookModel, w *cli.Webhoo state.CreatedBy = types.StringValue(w.CreatedBy) state.UpdatedAt = types.StringValue(w.UpdatedAt.String()) state.UpdatedBy = types.StringValue(w.UpdatedBy) + state.Url = types.StringValue(w.Url) + state.WebhookKey = types.StringValue(w.WebhookKey) state.Icon = flex.GoStringToFramework(w.Icon) state.Title = flex.GoStringToFramework(w.Title) state.Description = flex.GoStringToFramework(w.Description) diff --git a/port/webhook/resource.go b/port/webhook/resource.go index e63bac69..bdc29927 100644 --- a/port/webhook/resource.go +++ b/port/webhook/resource.go @@ -93,6 +93,8 @@ func writeWebhookComputedFieldsToState(state *WebhookModel, wp *cli.Webhook) { state.CreatedBy = types.StringValue(wp.CreatedBy) state.UpdatedAt = types.StringValue(wp.UpdatedAt.String()) state.UpdatedBy = types.StringValue(wp.UpdatedBy) + state.Url = types.StringValue(wp.Url) + state.WebhookKey = types.StringValue(wp.WebhookKey) } func (r *WebhookResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { diff --git a/port/webhook/resource_test.go b/port/webhook/resource_test.go index 6447dabe..f00413d8 100644 --- a/port/webhook/resource_test.go +++ b/port/webhook/resource_test.go @@ -52,6 +52,20 @@ func TestAccPortWebhookBasic(t *testing.T) { resource.TestCheckResourceAttr("port_webhook.create_pr", "title", "Test"), resource.TestCheckResourceAttr("port_webhook.create_pr", "icon", "Terraform"), resource.TestCheckResourceAttr("port_webhook.create_pr", "enabled", "true"), + resource.TestCheckResourceAttrWith("port_webhook.create_pr", "url", + func(value string) error { + if value == "" { + return fmt.Errorf("value is empty") + } + return nil + }), + resource.TestCheckResourceAttrWith("port_webhook.create_pr", "webhook_key", + func(value string) error { + if value == "" { + return fmt.Errorf("value is empty") + } + return nil + }), ), }, }, @@ -111,6 +125,20 @@ func TestAccPortWebhook(t *testing.T) { resource.TestCheckResourceAttr("port_webhook.create_pr", "title", "Test"), resource.TestCheckResourceAttr("port_webhook.create_pr", "icon", "Terraform"), resource.TestCheckResourceAttr("port_webhook.create_pr", "enabled", "true"), + resource.TestCheckResourceAttrWith("port_webhook.create_pr", "url", + func(value string) error { + if value == "" { + return fmt.Errorf("value is empty") + } + return nil + }), + resource.TestCheckResourceAttrWith("port_webhook.create_pr", "webhook_key", + func(value string) error { + if value == "" { + return fmt.Errorf("value is empty") + } + return nil + }), resource.TestCheckResourceAttr("port_webhook.create_pr", "security.signature_header_name", "X-Hub-Signature-256"), resource.TestCheckResourceAttr("port_webhook.create_pr", "security.signature_algorithm", "sha256"), resource.TestCheckResourceAttr("port_webhook.create_pr", "security.signature_prefix", "sha256="), @@ -181,6 +209,20 @@ func TestAccPortWebhookImport(t *testing.T) { resource.TestCheckResourceAttr("port_webhook.create_pr", "title", "Test"), resource.TestCheckResourceAttr("port_webhook.create_pr", "icon", "Terraform"), resource.TestCheckResourceAttr("port_webhook.create_pr", "enabled", "true"), + resource.TestCheckResourceAttrWith("port_webhook.create_pr", "url", + func(value string) error { + if value == "" { + return fmt.Errorf("value is empty") + } + return nil + }), + resource.TestCheckResourceAttrWith("port_webhook.create_pr", "webhook_key", + func(value string) error { + if value == "" { + return fmt.Errorf("value is empty") + } + return nil + }), resource.TestCheckResourceAttr("port_webhook.create_pr", "security.signature_header_name", "X-Hub-Signature-256"), resource.TestCheckResourceAttr("port_webhook.create_pr", "security.signature_algorithm", "sha256"), resource.TestCheckResourceAttr("port_webhook.create_pr", "security.signature_prefix", "sha256="), diff --git a/port/webhook/schema.go b/port/webhook/schema.go index 79e4e974..0acf44da 100644 --- a/port/webhook/schema.go +++ b/port/webhook/schema.go @@ -113,6 +113,14 @@ func WebhookSchema() map[string]schema.Attribute { Computed: true, Default: booldefault.StaticBool(false), }, + "url": schema.StringAttribute{ + MarkdownDescription: "The url of the webhook", + Computed: true, + }, + "webhook_key": schema.StringAttribute{ + MarkdownDescription: "The webhook key of the webhook", + Computed: true, + }, "security": schema.SingleNestedAttribute{ MarkdownDescription: "The security of the webhook", Optional: true,