Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb64c69b

Browse files
committed
chore: table formatter to correctly handle slices
1 parentf7668c1 commitb64c69b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

‎cli/cliui/table.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,21 @@ func renderTable(out any, sort string, headers table.Row, filterColumns []string
205205
}
206206
}
207207

208+
rt:=reflect.TypeOf(v)
209+
switchrt.Kind() {
210+
casereflect.Slice:
211+
// By default, the behavior is '%v', which just returns a string like
212+
// '[a b c]'. This will add commas in between each value.
213+
strs:=make([]string,0)
214+
vt:=reflect.ValueOf(v)
215+
fori:=0;i<vt.Len();i++ {
216+
strs=append(strs,fmt.Sprintf("%v",vt.Index(i).Interface()))
217+
}
218+
v="["+strings.Join(strs,", ")+"]"
219+
default:
220+
// Leave it as it is
221+
}
222+
208223
rowSlice[i]=v
209224
}
210225

‎enterprise/cli/organizationmembers_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import (
1515
"github.com/coder/coder/v2/testutil"
1616
)
1717

18-
funcTestEnterpriseListOrganization(t*testing.T) {
18+
funcTestEnterpriseListOrganizationMembers(t*testing.T) {
19+
t.Parallel()
20+
1921
t.Run("CustomRole",func(t*testing.T) {
2022
t.Parallel()
2123

@@ -29,9 +31,11 @@ func TestEnterpriseListOrganization(t *testing.T) {
2931
Features: license.Features{
3032
codersdk.FeatureCustomRoles:1,
3133
},
32-
}})
34+
},
35+
})
3336

3437
ctx:=testutil.Context(t,testutil.WaitMedium)
38+
//nolint:gocritic // only owners can patch roles
3539
customRole,err:=ownerClient.PatchOrganizationRole(ctx,owner.OrganizationID, codersdk.Role{
3640
Name:"custom",
3741
OrganizationID:owner.OrganizationID.String(),
@@ -47,7 +51,7 @@ func TestEnterpriseListOrganization(t *testing.T) {
4751
client,user:=coderdtest.CreateAnotherUser(t,ownerClient,owner.OrganizationID,rbac.RoleUserAdmin(), rbac.RoleIdentifier{
4852
Name:customRole.Name,
4953
OrganizationID:owner.OrganizationID,
50-
})
54+
},rbac.ScopedRoleOrgAdmin(owner.OrganizationID))
5155

5256
inv,root:=clitest.New(t,"organization","members","-c","user_id,username,organization_roles")
5357
clitest.SetupConfig(t,client,root)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp