Skip to content

[STORY-4371] feat(Organizations): Add scalingo orgs - #1282

Open
annabelle-scalingo wants to merge 9 commits into
masterfrom
STORY-4371/feat/orgs-command
Open

annabelle-scalingo wants to merge 9 commits into
masterfrom
STORY-4371/feat/orgs-command

Conversation

@annabelle-scalingo

@annabelle-scalingo annabelle-scalingo commented Oct 30, 2026 •

Copy link
Copy Markdown

add the scalingo orgs command to list organizations the current user belongs to
display organization ID, slug, and membership role
support both table and JSON output

update go-scalingo to 11.9.0 to get OrganizationsList (Scalingo/go-scalingo#540)

  • Add a changelog entry in the section "To Be Released" of CHANGELOG.md

@notion-workspace

Copy link
Copy Markdown

@annabelle-scalingo
annabelle-scalingo requested a review from a team as a code owner November 2, 2026 15:40
@annabelle-scalingo
annabelle-scalingo requested review from matthieu526-scalingo and removed request for a team November 2, 2026 15:40
Comment thread cmd/organizations.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: it could be organizations.go. I am not sure there is an advantage to the short name.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've renamed it, thanks!

Comment thread cmd/organizations.go

var (
orgsCommand = cli.Command{
Name: "orgs",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opinion: Reading the story I see this is what was chosen. My two cents, I would have kept the full name.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, that's the name that was chosen by Product, I didn't question myself
@aurelien-reeves-scalingo any thoughts about that?

@aurelien-reeves-scalingo aurelien-reeves-scalingo Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been specified that way by @leo-scalingo. He wanted to keep it that way

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I would be totally ok to have both, orgs and organizations as alias. But indeed in terminal if it doesn't impact too much semantic having orgs available is something I would push for

Comment thread cmd/organizations.go
format := renderer.Format(c.String("format"))

var orgsRenderer renderer.Renderer[[]scalingo.Organization]
switch format {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: will this automatically go for the table, even if it is not specified? (sorry it's been a while I've been in the cli)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the global --format flag defaults to table in scalingo/main.go
I checked on staging:
Screenshot 2026-11-03 at 08 37 27


func (r *orgsListRenderer) Render(ctx context.Context) error {
if len(r.organizations) == 0 {
fmt.Println("You are not a member of any organization.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: we have the io package (github.com/Scalingo/cli/io) avaible for messages, it might be better.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've updated!

t.Header([]string{"ID", "SLUG", "ROLE"})

for _, organization := range r.organizations {
err := t.Append([]string{organization.ID, organization.Slug, organization.Role})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we never handle that error, I am not sure it provides a lot of value. I think it would be acceptable to _ = it.

@annabelle-scalingo annabelle-scalingo Nov 3, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed to simplify, done

Comment thread orgs/list.go
return errors.Wrap(ctx, err, "get Scalingo client")
}

return list(ctx, c, r)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: that split of function doesn't provide a lot of value. Except if it is better for unit testing, otherwise I would merge the functions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the split is mainly for testing
it lets us inject a mocked OrganizationsService without depending on the global auth configuration

Comment thread orgs/list_test.go
"github.com/Scalingo/go-scalingo/v11/scalingomock"
)

type fakeRenderer struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: why not using a generated mock here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't find generated mocks in the repo for such cases (the only mocks used in tests come from go-scalingo's scalingomock)
i kept the small fakeRenderer in the test for now, but happy to update if you think it's better to generate a Renderer mock

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants