Skip to content

Commit

Permalink
Fix: Set allowed_domains when creating or updating a project [ODC-8…
Browse files Browse the repository at this point in the history
…87] (#37)

* fix: make the provider update the allowed domains key

* fix: use camelCase for naming
  • Loading branch information
taj-p authored Aug 24, 2022
1 parent 43a3f19 commit 0ba5630
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions sentry/resource_sentry_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func resourceSentryProjectRead(ctx context.Context, d *schema.ResourceData, meta
d.Set("status", proj.Status),
d.Set("digests_min_delay", proj.DigestsMinDelay),
d.Set("digests_max_delay", proj.DigestsMaxDelay),
d.Set("allowed_domains", proj.AllowedDomains),
d.Set("resolve_age", proj.ResolveAge),
d.Set("project_id", proj.ID), // Deprecated
)
Expand Down Expand Up @@ -274,6 +275,15 @@ func resourceSentryProjectUpdate(ctx context.Context, d *schema.ResourceData, me
params.ResolveAge = sentry.Int(v.(int))
}

if v, ok := d.GetOk("allowed_domains"); ok {
allowedDomainsSet := v.(*schema.Set)
allowedDomains := make([]string, allowedDomainsSet.Len())
for i, domain := range allowedDomainsSet.List() {
allowedDomains[i] = domain.(string)
}
params.AllowedDomains = allowedDomains
}

tflog.Debug(ctx, "Updating project", map[string]interface{}{
"org": org,
"project": project,
Expand Down
4 changes: 2 additions & 2 deletions sentry/resource_sentry_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestAccSentryProject_basic(t *testing.T) {
ImportStateVerify: true,
// TODO: Until we update go-sentry to include these attributes in its project.Get function,
// we will ignore them for now.
ImportStateVerifyIgnore: []string{"allowed_domains", "remove_default_key", "remove_default_rule"},
ImportStateVerifyIgnore: []string{"remove_default_key", "remove_default_rule"},
},
},
})
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestAccSentryProject_teams(t *testing.T) {
ImportStateVerify: true,
// TODO: Until we update go-sentry to include these attributes in its project.Get function,
// we will ignore them for now.
ImportStateVerifyIgnore: []string{"allowed_domains", "remove_default_key", "remove_default_rule"},
ImportStateVerifyIgnore: []string{"remove_default_key", "remove_default_rule"},
},
},
})
Expand Down

0 comments on commit 0ba5630

Please sign in to comment.