Skip to content

Commit 8fbe3ab

Browse files
kiwicoppleavalletesweatybridge
authored
chore: sync API types from infrastructure (#4448)
* chore: sync API types from infrastructure * chore: use org slug instead of org id --------- Co-authored-by: avallete <8771783+avallete@users.noreply.github.com> Co-authored-by: Qiao Han <qiao@supabase.io>
1 parent 10cdd70 commit 8fbe3ab

File tree

8 files changed

+72
-45
lines changed

8 files changed

+72
-45
lines changed

cmd/projects.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ var (
7575
projectName = args[0]
7676
}
7777
body := api.V1CreateProjectBody{
78-
Name: projectName,
79-
OrganizationId: orgId,
80-
DbPass: dbPassword,
81-
Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)),
78+
Name: projectName,
79+
OrganizationSlug: orgId,
80+
DbPass: dbPassword,
81+
Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)),
8282
}
8383
if cmd.Flags().Changed("size") {
8484
body.DesiredInstanceSize = (*api.V1CreateProjectBodyDesiredInstanceSize)(&size.Value)

internal/projects/create/create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) err
3838
`
3939
table += fmt.Sprintf(
4040
"|`%s`|`%s`|`%s`|`%s`|`%s`|\n",
41-
resp.JSON201.OrganizationId,
41+
resp.JSON201.OrganizationSlug,
4242
resp.JSON201.Id,
4343
strings.ReplaceAll(resp.JSON201.Name, "|", "\\|"),
4444
utils.FormatRegion(resp.JSON201.Region),
@@ -64,11 +64,11 @@ func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBody) err
6464
} else {
6565
fmt.Fprintln(os.Stderr, printKeyValue("Creating project", body.Name))
6666
}
67-
if len(body.OrganizationId) == 0 {
68-
if body.OrganizationId, err = promptOrgId(ctx); err != nil {
67+
if len(body.OrganizationSlug) == 0 {
68+
if body.OrganizationSlug, err = promptOrgId(ctx); err != nil {
6969
return err
7070
}
71-
fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationId))
71+
fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationSlug))
7272
}
7373
if body.Region == nil || len(*body.Region) == 0 {
7474
region, err := promptProjectRegion(ctx)

internal/projects/create/create_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import (
1616

1717
func TestProjectCreateCommand(t *testing.T) {
1818
var params = api.V1CreateProjectBody{
19-
Name: "Test Project",
20-
OrganizationId: "combined-fuchsia-lion",
21-
DbPass: "redacted",
22-
Region: cast.Ptr(api.V1CreateProjectBodyRegionUsWest1),
19+
Name: "Test Project",
20+
OrganizationSlug: "combined-fuchsia-lion",
21+
DbPass: "redacted",
22+
Region: cast.Ptr(api.V1CreateProjectBodyRegionUsWest1),
2323
}
2424

2525
t.Run("creates a new project", func(t *testing.T) {
@@ -36,11 +36,11 @@ func TestProjectCreateCommand(t *testing.T) {
3636
JSON(params).
3737
Reply(201).
3838
JSON(api.V1ProjectResponse{
39-
Id: apitest.RandomProjectRef(),
40-
OrganizationId: params.OrganizationId,
41-
Name: params.Name,
42-
Region: string(*params.Region),
43-
CreatedAt: "2022-04-25T02:14:55.906498Z",
39+
Id: apitest.RandomProjectRef(),
40+
OrganizationSlug: params.OrganizationSlug,
41+
Name: params.Name,
42+
Region: string(*params.Region),
43+
CreatedAt: "2022-04-25T02:14:55.906498Z",
4444
})
4545
// Run test
4646
assert.NoError(t, Run(context.Background(), params, fsys))

internal/projects/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
4949
table += fmt.Sprintf(
5050
"|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n",
5151
formatBullet(project.Linked),
52-
project.OrganizationId,
52+
project.OrganizationSlug,
5353
project.Id,
5454
strings.ReplaceAll(project.Name, "|", "\\|"),
5555
utils.FormatRegion(project.Region),

internal/projects/list/list_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ func TestProjectListCommand(t *testing.T) {
2727
Reply(200).
2828
JSON([]api.V1ProjectResponse{
2929
{
30-
Id: apitest.RandomProjectRef(),
31-
OrganizationId: "combined-fuchsia-lion",
32-
Name: "Test Project",
33-
Region: "us-west-1",
34-
CreatedAt: "2022-04-25T02:14:55.906498Z",
30+
Id: apitest.RandomProjectRef(),
31+
OrganizationSlug: "combined-fuchsia-lion",
32+
Name: "Test Project",
33+
Region: "us-west-1",
34+
CreatedAt: "2022-04-25T02:14:55.906498Z",
3535
},
3636
})
3737
// Run test

internal/utils/flags/project_ref.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func PromptProjectRef(ctx context.Context, title string, opts ...tea.ProgramOpti
3939
for i, project := range *resp.JSON200 {
4040
items[i] = utils.PromptItem{
4141
Summary: project.Id,
42-
Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationId, project.Region),
42+
Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationSlug, project.Region),
4343
}
4444
}
4545
choice, err := utils.PromptChoice(ctx, title, items, opts...)

internal/utils/flags/project_ref_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ func TestProjectPrompt(t *testing.T) {
7878
Get("/v1/projects").
7979
Reply(http.StatusOK).
8080
JSON([]api.V1ProjectResponse{{
81-
Id: "test-project",
82-
Name: "My Project",
83-
OrganizationId: "test-org",
81+
Id: "test-project",
82+
Name: "My Project",
83+
OrganizationSlug: "test-org",
8484
}})
8585
// Run test
8686
err := PromptProjectRef(context.Background(), "", input)

pkg/api/types.gen.go

Lines changed: 45 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)