Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: migrate project resource to framework #487

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ output "team" {

resource "sentry_project" "main" {
organization = sentry_team.main.organization
team = sentry_team.main.id
teams = [sentry_team.main.id]
name = "My project"
platform = "python"
}
Expand Down
6 changes: 3 additions & 3 deletions docs/resources/organization_code_mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ data "sentry_organization_integration" "github" {
resource "sentry_project" "this" {
organization = "my-organization"

team = "my-team"
name = "Web App"
slug = "web-app"
teams = ["my-team"]
name = "Web App"
slug = "web-app"

platform = "javascript"
resolve_age = 720
Expand Down
10 changes: 2 additions & 8 deletions docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ resource "sentry_project" "default" {

- `name` (String) The name for the project.
- `organization` (String) The slug of the organization the project belongs to.
- `teams` (Set of String) The slugs of the teams to create the project for.

### Optional

Expand All @@ -45,19 +46,12 @@ resource "sentry_project" "default" {
- `platform` (String) The platform for this project. For a list of valid values, [see this page](https://github.com/jianyuan/terraform-provider-sentry/blob/main/internal/sentryplatforms/platforms.txt). Use `other` for platforms not listed.
- `resolve_age` (Number) Hours in which an issue is automatically resolve if not seen after this amount of time.
- `slug` (String) The optional slug for this project.
- `team` (String, Deprecated) The slug of the team to create the project for. **Deprecated** Use `teams` instead.
- `teams` (Set of String) The slugs of the teams to create the project for.

### Read-Only

- `color` (String)
- `features` (List of String)
- `features` (Set of String)
- `id` (String) The ID of this resource.
- `internal_id` (String) The internal ID for this project.
- `is_bookmarked` (Boolean, Deprecated)
- `is_public` (Boolean)
- `project_id` (String, Deprecated) Use `internal_id` instead.
- `status` (String)

## Import

Expand Down
2 changes: 1 addition & 1 deletion examples/kitchen-sink/demo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ output "team" {

resource "sentry_project" "main" {
organization = sentry_team.main.organization
team = sentry_team.main.id
teams = [sentry_team.main.id]
name = "My project"
platform = "python"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ data "sentry_organization_integration" "github" {
resource "sentry_project" "this" {
organization = "my-organization"

team = "my-team"
name = "Web App"
slug = "web-app"
teams = ["my-team"]
name = "Web App"
slug = "web-app"

platform = "javascript"
resolve_age = 720
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/jianyuan/terraform-provider-sentry
go 1.21

require (
github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/hashicorp/terraform-plugin-docs v0.19.4
Expand All @@ -22,6 +21,7 @@ require (
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/yuin/goldmark v1.7.1 // indirect
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/data_source_all_client_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func TestAccAllClientKeysDataSource(t *testing.T) {
}

func testAccAllClientKeysDataSourceConfig(teamName, projectName string) string {
return testAccProjectResourceConfig(teamName, projectName) + `
return testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: projectName,
}) + `
data "sentry_all_keys" "test" {
organization = sentry_project.test.organization
project = sentry_project.test.id
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/data_source_client_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ func TestAccClientKeyDataSource_first(t *testing.T) {
}

func testAccClientKeyDataSourceConfig_bare(teamName, projectName string) string {
return testAccProjectResourceConfig(teamName, projectName) + `
return testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: projectName,
}) + `
data "sentry_key" "test" {
organization = sentry_project.test.organization
project = sentry_project.test.id
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/data_source_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ func TestAccProjectDataSource_UpgradeFromVersion(t *testing.T) {
}

func testAccProjectDataSourceConfig(teamName, projectName string) string {
return testAccProjectResourceConfig(teamName, projectName) + `
return testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: projectName,
}) + `
data "sentry_project" "test" {
organization = sentry_project.test.organization
slug = sentry_project.test.id
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (p *SentryProvider) Resources(ctx context.Context) []func() resource.Resour
NewIssueAlertResource,
NewNotificationActionResource,
NewProjectInboundDataFilterResource,
NewProjectResource,
NewProjectSpikeProtectionResource,
NewProjectSymbolSourcesResource,
NewTeamMemberResource,
Expand Down
15 changes: 12 additions & 3 deletions internal/provider/resource_all_projects_spike_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ func TestAccAllProjectsSpikeProtectionResource(t *testing.T) {
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccProjectResourceConfig(teamName, project1Name) + `
Config: testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: project1Name,
}) + `
resource "sentry_all_projects_spike_protection" "test" {
organization = sentry_team.test.organization
projects = [sentry_project.test.id]
Expand All @@ -42,7 +45,10 @@ func TestAccAllProjectsSpikeProtectionResource(t *testing.T) {
),
},
{
Config: testAccProjectResourceConfig(teamName, project1Name) + `
Config: testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: project1Name,
}) + `
resource "sentry_all_projects_spike_protection" "test" {
organization = sentry_team.test.organization
projects = [sentry_project.test.id]
Expand All @@ -58,7 +64,10 @@ func TestAccAllProjectsSpikeProtectionResource(t *testing.T) {
),
},
{
Config: testAccProjectResourceConfig(teamName, project1Name) + fmt.Sprintf(`
Config: testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: project1Name,
}) + fmt.Sprintf(`
resource "sentry_project" "test2" {
organization = sentry_team.test.organization
teams = [sentry_team.test.id]
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/resource_client_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ func TestAccClientKeyResource(t *testing.T) {
}

func testAccClientKeyResourceConfig(teamName, projectName, keyName, extras string) string {
return testAccProjectResourceConfig(teamName, projectName) + fmt.Sprintf(`
return testAccProjectResourceConfig(testAccProjectResourceConfigData{
TeamName: teamName,
ProjectName: projectName,
}) + fmt.Sprintf(`
resource "sentry_key" "test" {
organization = sentry_project.test.organization
project = sentry_project.test.id
Expand Down
Loading