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
8 changes: 4 additions & 4 deletions cmd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ var (
projectName = args[0]
}
body := api.V1CreateProjectBody{
Name: projectName,
OrganizationId: orgId,
DbPass: dbPassword,
Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)),
Name: projectName,
OrganizationSlug: orgId,
DbPass: dbPassword,
Region: cast.Ptr(api.V1CreateProjectBodyRegion(region.Value)),
}
if cmd.Flags().Changed("size") {
body.DesiredInstanceSize = (*api.V1CreateProjectBodyDesiredInstanceSize)(&size.Value)
Expand Down
8 changes: 4 additions & 4 deletions internal/projects/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) err
`
table += fmt.Sprintf(
"|`%s`|`%s`|`%s`|`%s`|`%s`|\n",
resp.JSON201.OrganizationId,
resp.JSON201.OrganizationSlug,
resp.JSON201.Id,
strings.ReplaceAll(resp.JSON201.Name, "|", "\\|"),
utils.FormatRegion(resp.JSON201.Region),
Expand All @@ -64,11 +64,11 @@ func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBody) err
} else {
fmt.Fprintln(os.Stderr, printKeyValue("Creating project", body.Name))
}
if len(body.OrganizationId) == 0 {
if body.OrganizationId, err = promptOrgId(ctx); err != nil {
if len(body.OrganizationSlug) == 0 {
if body.OrganizationSlug, err = promptOrgId(ctx); err != nil {
return err
}
fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationId))
fmt.Fprintln(os.Stderr, printKeyValue("Selected org-id", body.OrganizationSlug))
}
if body.Region == nil || len(*body.Region) == 0 {
region, err := promptProjectRegion(ctx)
Expand Down
18 changes: 9 additions & 9 deletions internal/projects/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (

func TestProjectCreateCommand(t *testing.T) {
var params = api.V1CreateProjectBody{
Name: "Test Project",
OrganizationId: "combined-fuchsia-lion",
DbPass: "redacted",
Region: cast.Ptr(api.V1CreateProjectBodyRegionUsWest1),
Name: "Test Project",
OrganizationSlug: "combined-fuchsia-lion",
DbPass: "redacted",
Region: cast.Ptr(api.V1CreateProjectBodyRegionUsWest1),
}

t.Run("creates a new project", func(t *testing.T) {
Expand All @@ -36,11 +36,11 @@ func TestProjectCreateCommand(t *testing.T) {
JSON(params).
Reply(201).
JSON(api.V1ProjectResponse{
Id: apitest.RandomProjectRef(),
OrganizationId: params.OrganizationId,
Name: params.Name,
Region: string(*params.Region),
CreatedAt: "2022-04-25T02:14:55.906498Z",
Id: apitest.RandomProjectRef(),
OrganizationSlug: params.OrganizationSlug,
Name: params.Name,
Region: string(*params.Region),
CreatedAt: "2022-04-25T02:14:55.906498Z",
})
// Run test
assert.NoError(t, Run(context.Background(), params, fsys))
Expand Down
2 changes: 1 addition & 1 deletion internal/projects/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
table += fmt.Sprintf(
"|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n",
formatBullet(project.Linked),
project.OrganizationId,
project.OrganizationSlug,
project.Id,
strings.ReplaceAll(project.Name, "|", "\\|"),
utils.FormatRegion(project.Region),
Expand Down
10 changes: 5 additions & 5 deletions internal/projects/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func TestProjectListCommand(t *testing.T) {
Reply(200).
JSON([]api.V1ProjectResponse{
{
Id: apitest.RandomProjectRef(),
OrganizationId: "combined-fuchsia-lion",
Name: "Test Project",
Region: "us-west-1",
CreatedAt: "2022-04-25T02:14:55.906498Z",
Id: apitest.RandomProjectRef(),
OrganizationSlug: "combined-fuchsia-lion",
Name: "Test Project",
Region: "us-west-1",
CreatedAt: "2022-04-25T02:14:55.906498Z",
},
})
// Run test
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/flags/project_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func PromptProjectRef(ctx context.Context, title string, opts ...tea.ProgramOpti
for i, project := range *resp.JSON200 {
items[i] = utils.PromptItem{
Summary: project.Id,
Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationId, project.Region),
Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationSlug, project.Region),
}
}
choice, err := utils.PromptChoice(ctx, title, items, opts...)
Expand Down
6 changes: 3 additions & 3 deletions internal/utils/flags/project_ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func TestProjectPrompt(t *testing.T) {
Get("/v1/projects").
Reply(http.StatusOK).
JSON([]api.V1ProjectResponse{{
Id: "test-project",
Name: "My Project",
OrganizationId: "test-org",
Id: "test-project",
Name: "My Project",
OrganizationSlug: "test-org",
}})
// Run test
err := PromptProjectRef(context.Background(), "", input)
Expand Down
63 changes: 45 additions & 18 deletions pkg/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading