Repository navigation
feat(organizations): display the organization slug in projects - #1287
Conversation
|
the tests are currently failing because the CLI depends on SDK changes that haven't been released yet before publishing a new SDK version, I'd like to get your thoughts on the approach: i initially chose to keep the existing i'm wondering if this is the right approach, or if it would make more sense to expose an endpoint (or add a params to the existing one) to retrieve all the user's projects in a single request WDYT @aurelien-reeves-scalingo ? |
|
I do not expect users to have a lot of organizations, so fetching projects with a few requests don't bother me. @EtienneM would you have a preference? |
Don't we want to write something to make it explicit that it's a personal project?
You can include these changes in the PR so that you can have the CI succeeded with: go get github.com/Scalingo/go-scalingo/v11@<branch name>
go mod vendor
go mod tidy
We are used to make multiple API requests in the CLI to retrieve all the information we need. I like the idea of having API endpoint doing a single and simple job. Hence I would make multiple API requests. If we eventually have performance issues, we can reconsider this choice. But premature optimization is the root of all evil. And as pointed out by Aurélien, we don't expect users to have a lot of organizations. Hence we probably won't have that many requests. |
…label personal projects Display `personal` in the ORGANIZATION column for personal projects and drop the bounded concurrency: the SDK client is not documented as safe for concurrent use, and one request per organization is enough here. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I gave a try to display the column contains organization slugs, users might interpret I think keeping the column empty for projects without an organization, as originally planned, would be less ambiguous (thanks for the tips and for your inputs) |
EtienneM
left a comment
There was a problem hiding this comment.
I think keeping the column empty for projects without an organization, as originally planned, would be less ambiguous
WDYT?
Thanks for giving it a try. I didn't know that personal projects were only temporary. Let's keep it empty for now and we will see if it raises questions on our customers side :)
| type projectsLister interface { | ||
| ProjectsList(ctx context.Context) ([]scalingo.Project, error) | ||
| ProjectsListByOrganization(ctx context.Context, organizationID string) ([]scalingo.Project, error) | ||
| } |
There was a problem hiding this comment.
issue: we don't usually declare an interface here. We already have the interface ProjectsService in go-scalingo that should be mocked in the go-scalingo mocks.json.
| projects, err := listWithOrganizations(ctx, c, c) | ||
| if err != nil { | ||
| return errors.Wrap(ctx, err, "list projects") | ||
| return err |
There was a problem hiding this comment.
issue: all errors must be wrapped
| return err | |
| return errors.Wrap(ctx, err, "list projects with organizations") |
| } | ||
|
|
||
| projects, err := c.ProjectsList(ctx) | ||
| projects, err := listWithOrganizations(ctx, c, c) |
There was a problem hiding this comment.
suggestion: I'm not convinced by these two c arguments here.
|
|
||
| t := tablewriter.NewWriter(os.Stdout) | ||
| t.Header([]string{"Name", "Default", "ID"}) | ||
| return render(os.Stdout, projects) |
There was a problem hiding this comment.
issue: all errors must be wrapped
| return render(os.Stdout, projects) | |
| listedProjects, err := render(os.Stdout, projects) | |
| if err != nil { | |
| nil, errors.Wrap(ctx, err, "render listed projects") | |
| } | |
| return listedProjects, nil |
| projects = append(projects, listedProject{project: project}) | ||
| } | ||
|
|
||
| // The authentication service can return the same organization several times. |
There was a problem hiding this comment.
question: isn't it odd that the backend service can return multiple times the same organizations? 😲
How is it possible that a listing endpoints have such a behaviour?
There was a problem hiding this comment.
i initially added the deduplication as a safeguard because a user could potentially have multiple membership records for the same organization (being removed and added back)
but soft-deleted memberships are excluded and I agree this shouldn't be handled in the CLI,
I've removed the deduplication and its test
|
|
||
| organizationProjects, err := projectsService.ProjectsListByOrganization(ctx, organization.ID) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(ctx, err, "list projects of organization %s", organization.Slug) |
There was a problem hiding this comment.
issue: we don't add slugs in error message
| return nil, errors.Wrapf(ctx, err, "list projects of organization %s", organization.Slug) | |
| return nil, errors.Wrap(ctx, err, "list organization projects") |
…ication Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
thanks for the review @EtienneM (and sorry for the extra time it took you, i'm not familiar with Go and the repo conventions)! i've fixed the error wrapping and deduplication comments for the remaining comments about interfaces, mocks and the duplicated
from what I understand, I would need to update
does that sound like the right approach to you, or do you have a simpler solution in mind? |
No problem, that's a pleasure to explain you these conventions. This highlights a lack of documentation, maybe in the go-scalingo README. I'll add that to my todo list.
I think that your solution matches what I had in mind. After doing this you'll unfortunately need to make a new go-scalingo release (patch version this time). |
…he projects Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
scalingo projectsnow shows the organization of each project (STORY-4375). Columns:NAME | ORGANIZATION | DEFAULT | IDORGANIZATION contains the organization slug, empty for a personal project.
flow:
ProjectsList(personal projects)OrganizationsList,ProjectsListByOrganizationcall per organizationChecklist