Skip to content

Commit

Permalink
[7/X] DXCDT-441: Reintroduce support for sentry client addon (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Jun 29, 2023
1 parent f3719fa commit 43cf573
Show file tree
Hide file tree
Showing 9 changed files with 340 additions and 82 deletions.
10 changes: 10 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Read-Only:
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))

<a id="nestedobjatt--addons--aws"></a>
Expand Down Expand Up @@ -138,6 +139,15 @@ Read-Only:
- `url` (String)


<a id="nestedobjatt--addons--sentry"></a>
### Nested Schema for `addons.sentry`

Read-Only:

- `base_url` (String)
- `org_slug` (String)


<a id="nestedobjatt--addons--slack"></a>
### Nested Schema for `addons.slack`

Expand Down
10 changes: 10 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Read-Only:
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))

<a id="nestedobjatt--addons--aws"></a>
Expand Down Expand Up @@ -127,6 +128,15 @@ Read-Only:
- `url` (String)


<a id="nestedobjatt--addons--sentry"></a>
### Nested Schema for `addons.sentry`

Read-Only:

- `base_url` (String)
- `org_slug` (String)


<a id="nestedobjatt--addons--slack"></a>
### Nested Schema for `addons.slack`

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Optional:
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `slack` (Block List, Max: 1) Slack team or workspace name usually first segment in your Slack URL, for example `https://acme-org.slack.com` would be `acme-org`. (see [below for nested schema](#nestedblock--addons--slack))

<a id="nestedblock--addons--aws"></a>
Expand Down Expand Up @@ -200,6 +201,15 @@ Optional:
- `url` (String) URL of your Rights Management Server. It can be internal or external, but users will have to be able to reach it.


<a id="nestedblock--addons--sentry"></a>
### Nested Schema for `addons.sentry`

Optional:

- `base_url` (String) URL prefix only if running Sentry Community Edition, otherwise leave empty.
- `org_slug` (String) Generated slug for your Sentry organization. Found in your Sentry URL, for example `https://sentry.acme.com/acme-org/` would be `acme-org`.


<a id="nestedblock--addons--slack"></a>
### Nested Schema for `addons.slack`

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Optional:
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `slack` (Block List, Max: 1) Slack team or workspace name usually first segment in your Slack URL, for example `https://acme-org.slack.com` would be `acme-org`. (see [below for nested schema](#nestedblock--addons--slack))

<a id="nestedblock--addons--aws"></a>
Expand Down Expand Up @@ -143,6 +144,15 @@ Optional:
- `url` (String) URL of your Rights Management Server. It can be internal or external, but users will have to be able to reach it.


<a id="nestedblock--addons--sentry"></a>
### Nested Schema for `addons.sentry`

Optional:

- `base_url` (String) URL prefix only if running Sentry Community Edition, otherwise leave empty.
- `org_slug` (String) Generated slug for your Sentry organization. Found in your Sentry URL, for example `https://sentry.acme.com/acme-org/` would be `acme-org`.


<a id="nestedblock--addons--slack"></a>
### Nested Schema for `addons.slack`

Expand Down
16 changes: 16 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.RMS = expandClientAddonRMS(addonsCfg.GetAttr("rms"))
addons.MSCRM = expandClientAddonMSCRM(addonsCfg.GetAttr("mscrm"))
addons.Slack = expandClientAddonSlack(addonsCfg.GetAttr("slack"))
addons.Sentry = expandClientAddonSentry(addonsCfg.GetAttr("sentry"))
return stop
})

Expand Down Expand Up @@ -374,6 +375,21 @@ func expandClientAddonSlack(slackCfg cty.Value) *management.SlackClientAddon {
return &slackAddon
}

func expandClientAddonSentry(sentryCfg cty.Value) *management.SentryClientAddon {
var sentryAddon management.SentryClientAddon

sentryCfg.ForEachElement(func(_ cty.Value, sentryCfg cty.Value) (stop bool) {
sentryAddon = management.SentryClientAddon{
OrgSlug: value.String(sentryCfg.GetAttr("org_slug")),
BaseURL: value.String(sentryCfg.GetAttr("base_url")),
}

return stop
})

return &sentryAddon
}

func clientHasChange(c *management.Client) bool {
return c.String() != "{}"
}
10 changes: 10 additions & 0 deletions internal/auth0/client/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"rms": nil,
"mscrm": nil,
"slack": nil,
"sentry": nil,
}

if addons.GetAWS() != nil {
Expand Down Expand Up @@ -169,5 +170,14 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
}
}

if addons.GetSentry() != nil {
m["sentry"] = []interface{}{
map[string]interface{}{
"org_slug": addons.GetSentry().GetOrgSlug(),
"base_url": addons.GetSentry().GetBaseURL(),
},
}
}

return []interface{}{m}
}
24 changes: 24 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,30 @@ func NewResource() *schema.Resource {
},
},
},
"sentry": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Sentry SSO configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"org_slug": {
Description: "Generated slug for your Sentry organization. Found in your " +
"Sentry URL, for example `https://sentry.acme.com/acme-org/` would be " +
"`acme-org`.",
Type: schema.TypeString,
Optional: true,
},
"base_url": {
Description: "URL prefix only if running Sentry Community Edition, otherwise leave empty.",
Type: schema.TypeString,
ValidateFunc: internalValidation.IsURLWithHTTPSorEmptyString,
Optional: true,
},
},
},
},
},
},
},
Expand Down
24 changes: 24 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,20 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsSentry = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
sentry {
org_slug = "acmeorg"
base_url = ""
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -909,6 +923,16 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.slack.0.team", "acmeorg"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsSentry, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_client.my_client", "name", fmt.Sprintf("Acceptance Test - SSO Integration - %s", t.Name())),
resource.TestCheckResourceAttr("auth0_client.my_client", "app_type", "sso_integration"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.sentry.0.org_slug", "acmeorg"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.sentry.0.base_url", ""),
),
},
},
})
}
Expand Down
Loading

0 comments on commit 43cf573

Please sign in to comment.