feat(cli) Add All missing features of the Organizations API#263
Open
DerBurri wants to merge 17 commits into
Open
feat(cli) Add All missing features of the Organizations API#263DerBurri wants to merge 17 commits into
DerBurri wants to merge 17 commits into
Conversation
2452e6c to
1487f91
Compare
* add list organizations command Signed-off-by: Maximilian <burr.maximilian97@gmail.com> * chore(docs): Auto-update docs and licenses Signed-off-by: DerBurri <7892993+DerBurri@users.noreply.github.com> Signed-off-by: Maximilian <burr.maximilian97@gmail.com> * feat(test): removed old code Signed-off-by: Maximilian <burr.maximilian97@gmail.com> * feat(test): add coverage report Signed-off-by: Maximilian <burr.maximilian97@gmail.com> * add missing err checks for stdout closing Signed-off-by: Maximilian <burr.maximilian97@gmail.com> --------- Signed-off-by: Maximilian <burr.maximilian97@gmail.com> Signed-off-by: DerBurri <7892993+DerBurri@users.noreply.github.com> Co-authored-by: DerBurri <7892993+DerBurri@users.noreply.github.com> Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: DerBurri <7892993+DerBurri@users.noreply.github.com> Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
chore(mock): Update MockClient.ListTeams signature test(cli): Update ListTeams mock expectation in list_workspaces_test feat(api): Add ConvertOrgTeamToTeam helper for organization teams refactor(cli): Simplify ListTeamsCmd.RunE to use new ListTeams signature feat(cli): Update Client interface for ListTeams to include orgId feat(cli): Add --org flag and GlobalOptions.OrgId for organization context feat(pkg): Add GetOrgId to Environment for CS_ORG_ID feat(cli): Implement 'cs list org' command to list organizations Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: DerBurri <7892993+DerBurri@users.noreply.github.com> Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
added team add and delete opton with org context Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: DerBurri <7892993+DerBurri@users.noreply.github.com> Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
044e3a4 to
a513836
Compare
Signed-off-by: Maximilian <burr.maximilian97@gmail.com>
3ceec3c to
a58b8eb
Compare
Signed-off-by: DerBurri <7892993+DerBurri@users.noreply.github.com>
OliverTrautvetter
requested changes
Jun 3, 2026
OliverTrautvetter
left a comment
Member
There was a problem hiding this comment.
Nice feature, some comments for it 👍
| return orgId | ||
| } | ||
| return "" | ||
| } |
Member
There was a problem hiding this comment.
Why? It is like
if true return true
Maybe log something before return "" that CS_ORG_ID is not set
Comment on lines
+74
to
76
| if orgId == "" { | ||
| return "", nil | ||
| } |
Member
There was a problem hiding this comment.
why is it no longer an error?
Comment on lines
+28
to
+32
| cmd: &cobra.Command{ | ||
| Use: "add", | ||
| Short: "Add team member", | ||
| Long: `Add team member to a team`, | ||
| }, |
Member
There was a problem hiding this comment.
please add some Example: formatExamples
Comment on lines
+26
to
+31
| t := CreateTeamCmd{ | ||
| cmd: &cobra.Command{ | ||
| Use: "create", | ||
| Short: "Create team", | ||
| Long: `Create a team in Codesphere or an Organization`, | ||
| }, |
Member
There was a problem hiding this comment.
please add some Example: formatExamples
Comment on lines
+25
to
+30
| t := RemoveTeamCmd{ | ||
| cmd: &cobra.Command{ | ||
| Use: "remove", | ||
| Short: "Remove team", | ||
| Long: `Remove a team from Codesphere or an Organization`, | ||
| }, |
Member
There was a problem hiding this comment.
please add some Example: formatExamples
| ClientFactory: NewClient, | ||
| } | ||
| t.cmd.RunE = t.RunE | ||
| t.cmd.Flags().StringVarP(&t.Opts.Name, "name", "n", "", "Team name") |
Member
There was a problem hiding this comment.
name flag should be MarkFlagRequired too
| ClientFactory: NewClient, | ||
| } | ||
| t.cmd.RunE = t.RunE | ||
| t.cmd.Flags().StringVarP(&t.Opts.name, "name", "n", "", "Team name") |
|
|
||
| teamId, err := c.Opts.GetTeamId() | ||
| if err != nil { | ||
| return errors.New("team ID not set, use -T or CS_TEAM_ID to set it") |
| }, | ||
| ClientFactory: NewClient, | ||
| } | ||
| res.cmd.Flags().IntVarP(&res.Opts.UserId, "user", "u", 0, "Team member user ID") |
| } | ||
|
|
||
| func (c *RemoveTeamMemberCmd) RemoveTeamMember(client Client, teamId int, userId int) error { | ||
| if userId == 0 { |
Member
There was a problem hiding this comment.
can userId be -1? Maybe we should check if <= 0 -> error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch implements org-aware team functionality across the CLI and API client, adds unit tests for team flows, and makes client creation injectable to improve testability. It also includes several refactors and dependency updates required to support the new behavior.
Organization-aware team behavior:
Use GlobalOptions.OrgId and environment GetOrgId() for org-scoped commands.
Add organization filtering to ListTeams and helper conversions for org teams (API + CLI).
Team management commands and tests:
Implement and test AddTeamMember and RemoveTeamMember command logic and validation.
Implement and test team deletion (RemoveTeam) with injectible ClientFactory to mock API calls.
Add/extend unit tests for create/add/remove team flows.
Error handling & observability:
Improve API error logging to include traceId.
Centralize API error formatting via api/errors.FormatAPIError.
Testability & infra:
Make client construction injectable for CLI commands to allow mocks in tests.
Build-and-run integration test workflow updated (artifact + label matrix) — see integration-test.yml.
Chores & deps:
Multiple dependency updates and lint/test chore fixes.
Representative commits
CLI commands: team_create.go, team_add_member.go, team_remove_member.go, team_remove.go
Tests: team_create_test.go, team_add_member_test.go, team_remove_member_test.go, team_remove_test.go
API error handling: errors.go, tests in errors_test.go
CI workflow: integration-test.yml
Client interface and mocks: client.go, mocks.go
Testing / verification
Ran unit tests for the CLI package locally: go test ./cli/cmd — passing.
Integration tests are built and run via the updated GitHub Actions workflow; note that some int tests previously observed backend HTTP 500s during workspace deletion (server-side). If CI shows failures, collect trace IDs and forward to backend logs for investigation.
Migration / usage notes