Skip to content

Commit b124886

Browse files
committed
fix: rename project ref attribute for consistency
1 parent 4f4f315 commit b124886

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

docs/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ resource "supabase_project" "production" {
4444
4545
# Retrieve project API keys
4646
data "supabase_project_apikeys" "production" {
47-
project_id = supabase_project.production.id
47+
project_ref = supabase_project.production.id
4848
}
4949
5050
# Output the API keys (careful with sensitive data!)
@@ -94,7 +94,7 @@ resource "supabase_project" "production" {
9494
9595
# Retrieve project API keys
9696
data "supabase_project_apikeys" "production" {
97-
project_id = supabase_project.production.id
97+
project_ref = supabase_project.production.id
9898
}
9999
```
100100

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "supabase_project_apikeys" "production" {
2+
project_ref = "mayuaycdtijbctgqbycg"
3+
}

examples/examples.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ var (
1313
BranchDataSourceConfig string
1414
//go:embed data-sources/supabase_pooler/data-source.tf
1515
PoolerDataSourceConfig string
16+
//go:embed data-sources/supabase_project_apikeys/data-source.tf
17+
ProjectAPIKeysDataSourceConfig string
1618
)

internal/provider/project_apikeys_data_source.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type ProjectAPIKeysDataSource struct {
2828

2929
// ProjectAPIKeysDataSourceModel describes the data source data model.
3030
type ProjectAPIKeysDataSourceModel struct {
31-
ProjectId types.String `tfsdk:"project_id"`
31+
ProjectRef types.String `tfsdk:"project_ref"`
3232
AnonKey types.String `tfsdk:"anon_key"`
3333
ServiceRoleKey types.String `tfsdk:"service_role_key"`
3434
}
@@ -42,8 +42,8 @@ func (d *ProjectAPIKeysDataSource) Schema(ctx context.Context, req datasource.Sc
4242
MarkdownDescription: "Project API Keys data source",
4343

4444
Attributes: map[string]schema.Attribute{
45-
"project_id": schema.StringAttribute{
46-
MarkdownDescription: "Project identifier",
45+
"project_ref": schema.StringAttribute{
46+
MarkdownDescription: "Project reference ID",
4747
Required: true,
4848
},
4949
"anon_key": schema.StringAttribute{
@@ -87,7 +87,7 @@ func (d *ProjectAPIKeysDataSource) Read(ctx context.Context, req datasource.Read
8787
return
8888
}
8989

90-
httpResp, err := d.client.V1GetProjectApiKeysWithResponse(ctx, data.ProjectId.ValueString(), &api.V1GetProjectApiKeysParams{})
90+
httpResp, err := d.client.V1GetProjectApiKeysWithResponse(ctx, data.ProjectRef.ValueString(), &api.V1GetProjectApiKeysParams{})
9191
if err != nil {
9292
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read project API keys, got error: %s", err))
9393
return

internal/provider/project_apikeys_data_source_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1111
"github.com/supabase/cli/pkg/api"
12+
"github.com/supabase/terraform-provider-supabase/examples"
1213
"gopkg.in/h2non/gock.v1"
1314
)
1415

@@ -36,7 +37,7 @@ func TestAccProjectAPIKeysDataSource(t *testing.T) {
3637
Steps: []resource.TestStep{
3738
// Read testing
3839
{
39-
Config: testAccProjectAPIKeysDataSourceConfig,
40+
Config: examples.ProjectAPIKeysDataSourceConfig,
4041
Check: resource.ComposeAggregateTestCheckFunc(
4142
resource.TestCheckResourceAttr("data.supabase_project_apikeys.production", "anon_key", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.anon"),
4243
resource.TestCheckResourceAttr("data.supabase_project_apikeys.production", "service_role_key", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.service_role"),
@@ -45,9 +46,3 @@ func TestAccProjectAPIKeysDataSource(t *testing.T) {
4546
},
4647
})
4748
}
48-
49-
const testAccProjectAPIKeysDataSourceConfig = `
50-
data "supabase_project_apikeys" "production" {
51-
project_id = "mayuaycdtijbctgqbycg"
52-
}
53-
`

0 commit comments

Comments
 (0)