Skip to content
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
4 changes: 2 additions & 2 deletions docs/resources/key.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ resource "sentry_key" "default" {

### Optional

- `javascript_loader_script` (Block, Optional) The JavaScript loader script configuration. (see [below for nested schema](#nestedblock--javascript_loader_script))
- `javascript_loader_script` (Attributes) The JavaScript loader script configuration. (see [below for nested schema](#nestedatt--javascript_loader_script))
- `rate_limit_count` (Number) Number of events that can be reported within the rate limit window.
- `rate_limit_window` (Number) Length of time in seconds that will be considered when checking the rate limit.

Expand All @@ -48,7 +48,7 @@ resource "sentry_key" "default" {
- `public` (String) The public key.
- `secret` (String) The secret key.

<a id="nestedblock--javascript_loader_script"></a>
<a id="nestedatt--javascript_loader_script"></a>
### Nested Schema for `javascript_loader_script`

Optional:
Expand Down
19 changes: 8 additions & 11 deletions internal/provider/data_source_all_client_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/jianyuan/terraform-provider-sentry/internal/apiclient"
Expand All @@ -21,19 +22,15 @@ type AllClientKeysDataSourceModel struct {
Keys []ClientKeyResourceModel `tfsdk:"keys"`
}

func (m *AllClientKeysDataSourceModel) Fill(keys []apiclient.ProjectKey) error {
func (m *AllClientKeysDataSourceModel) Fill(ctx context.Context, keys []apiclient.ProjectKey) (diags diag.Diagnostics) {
m.Keys = make([]ClientKeyResourceModel, len(keys))
for i, key := range keys {
if err := m.Keys[i].FillAll(
m.Organization.ValueString(),
m.Project.ValueString(),
key,
); err != nil {
return err
}
m.Keys[i].Organization = types.StringValue(m.Organization.ValueString())
m.Keys[i].Project = types.StringValue(m.Project.ValueString())
diags.Append(m.Keys[i].Fill(ctx, key)...)
}

return nil
return
}

var _ datasource.DataSource = &AllClientKeysDataSource{}
Expand Down Expand Up @@ -194,8 +191,8 @@ func (d *AllClientKeysDataSource) Read(ctx context.Context, req datasource.ReadR
}
}

if err := data.Fill(allKeys); err != nil {
resp.Diagnostics.Append(diagutils.NewFillError(err))
resp.Diagnostics.Append(data.Fill(ctx, allKeys)...)
if resp.Diagnostics.HasError() {
return
}

Expand Down
6 changes: 5 additions & 1 deletion internal/provider/data_source_client_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ data "sentry_key" "test" {
}

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