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

Commit97d314e

Browse files
committed
Merge branch 'main' of github.com:/coder/coder into dk/prebuilds
2 parentsc0f6922 +9ded2cc commit97d314e

File tree

124 files changed

+1296
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1296
-648
lines changed

‎.vscode/markdown.code-snippets

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
// For info about snippets, visit https://code.visualstudio.com/docs/editor/userdefinedsnippets
3+
// https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
34

4-
"admonition": {
5-
"prefix":"#callout",
5+
"alert": {
6+
"prefix":"#alert",
67
"body": [
7-
"<blockquote class=\"admonition ${1|caution,important,note,tip,warning|}\">\n",
8-
"${TM_SELECTED_TEXT:${2:add info here}}\n",
9-
"</blockquote>\n"
8+
"> [!${1|CAUTION,IMPORTANT,NOTE,TIP,WARNING|}]",
9+
"> ${TM_SELECTED_TEXT:${2:add info here}}\n"
1010
],
11-
"description":"callout admonition cautioninfo note tip warning"
11+
"description":"callout admonition cautionimportant note tip warning"
1212
},
1313
"fenced code block": {
1414
"prefix":"#codeblock",
@@ -23,9 +23,8 @@
2323
"premium-feature": {
2424
"prefix":"#premium-feature",
2525
"body": [
26-
"<blockquote class=\"info\">\n",
27-
"${1:feature} ${2|is,are|} an Enterprise and Premium feature. [Learn more](https://coder.com/pricing#compare-plans).\n",
28-
"</blockquote>"
26+
"> [!NOTE]\n",
27+
"> ${1:feature} ${2|is,are|} an Enterprise and Premium feature. [Learn more](https://coder.com/pricing#compare-plans).\n"
2928
]
3029
},
3130
"tabs": {

‎agent/agent_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
"github.com/coder/coder/v2/agent/agentssh"
5252
"github.com/coder/coder/v2/agent/agenttest"
5353
"github.com/coder/coder/v2/agent/proto"
54+
"github.com/coder/coder/v2/agent/usershell"
5455
"github.com/coder/coder/v2/codersdk"
5556
"github.com/coder/coder/v2/codersdk/agentsdk"
5657
"github.com/coder/coder/v2/codersdk/workspacesdk"
@@ -1193,6 +1194,53 @@ func TestAgent_SSHConnectionEnvVars(t *testing.T) {
11931194
}
11941195
}
11951196

1197+
funcTestAgent_SSHConnectionLoginVars(t*testing.T) {
1198+
t.Parallel()
1199+
1200+
envInfo:= usershell.SystemEnvInfo{}
1201+
u,err:=envInfo.User()
1202+
require.NoError(t,err,"get current user")
1203+
shell,err:=envInfo.Shell(u.Username)
1204+
require.NoError(t,err,"get current shell")
1205+
1206+
tests:= []struct {
1207+
keystring
1208+
wantstring
1209+
}{
1210+
{
1211+
key:"USER",
1212+
want:u.Username,
1213+
},
1214+
{
1215+
key:"LOGNAME",
1216+
want:u.Username,
1217+
},
1218+
{
1219+
key:"HOME",
1220+
want:u.HomeDir,
1221+
},
1222+
{
1223+
key:"SHELL",
1224+
want:shell,
1225+
},
1226+
}
1227+
for_,tt:=rangetests {
1228+
tt:=tt
1229+
t.Run(tt.key,func(t*testing.T) {
1230+
t.Parallel()
1231+
1232+
session:=setupSSHSession(t, agentsdk.Manifest{}, codersdk.ServiceBannerConfig{},nil)
1233+
command:="sh -c 'echo $"+tt.key+"'"
1234+
ifruntime.GOOS=="windows" {
1235+
command="cmd.exe /c echo %"+tt.key+"%"
1236+
}
1237+
output,err:=session.Output(command)
1238+
require.NoError(t,err)
1239+
require.Equal(t,tt.want,strings.TrimSpace(string(output)))
1240+
})
1241+
}
1242+
}
1243+
11961244
funcTestAgent_Metadata(t*testing.T) {
11971245
t.Parallel()
11981246

‎agent/agentssh/agentssh.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,10 @@ func (s *Server) CreateCommand(ctx context.Context, script string, env []string,
900900
cmd.Dir=homedir
901901
}
902902
cmd.Env=append(ei.Environ(),env...)
903+
// Set login variables (see `man login`).
903904
cmd.Env=append(cmd.Env,fmt.Sprintf("USER=%s",username))
905+
cmd.Env=append(cmd.Env,fmt.Sprintf("LOGNAME=%s",username))
906+
cmd.Env=append(cmd.Env,fmt.Sprintf("SHELL=%s",shell))
904907

905908
// Set SSH connection environment variables (these are also set by OpenSSH
906909
// and thus expected to be present by SSH clients). Since the agent does

‎coderd/apidoc/docs.go

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ func New(options *Options) *API {
10051005
})
10061006
})
10071007
})
1008+
r.Get("/paginated-members",api.paginatedMembers)
10081009
r.Route("/members",func(r chi.Router) {
10091010
r.Get("/",api.listMembers)
10101011
r.Route("/roles",func(r chi.Router) {

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3632,6 +3632,14 @@ func (q *querier) OrganizationMembers(ctx context.Context, arg database.Organiza
36323632
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.OrganizationMembers)(ctx,arg)
36333633
}
36343634

3635+
func (q*querier)PaginatedOrganizationMembers(ctx context.Context,arg database.PaginatedOrganizationMembersParams) ([]database.PaginatedOrganizationMembersRow,error) {
3636+
// Required to have permission to read all members in the organization
3637+
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceOrganizationMember.InOrg(arg.OrganizationID));err!=nil {
3638+
returnnil,err
3639+
}
3640+
returnq.db.PaginatedOrganizationMembers(ctx,arg)
3641+
}
3642+
36353643
func (q*querier)ReduceWorkspaceAgentShareLevelToAuthenticatedByTemplate(ctx context.Context,templateID uuid.UUID)error {
36363644
template,err:=q.db.GetTemplateByID(ctx,templateID)
36373645
iferr!=nil {

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,32 @@ func (s *MethodTestSuite) TestOrganization() {
985985
mem,policy.ActionRead,
986986
)
987987
}))
988+
s.Run("PaginatedOrganizationMembers",s.Subtest(func(db database.Store,check*expects) {
989+
o:=dbgen.Organization(s.T(),db, database.Organization{})
990+
u:=dbgen.User(s.T(),db, database.User{})
991+
mem:=dbgen.OrganizationMember(s.T(),db, database.OrganizationMember{
992+
OrganizationID:o.ID,
993+
UserID:u.ID,
994+
Roles: []string{rbac.RoleOrgAdmin()},
995+
})
996+
997+
check.Args(database.PaginatedOrganizationMembersParams{
998+
OrganizationID:o.ID,
999+
LimitOpt:0,
1000+
}).Asserts(
1001+
rbac.ResourceOrganizationMember.InOrg(o.ID),policy.ActionRead,
1002+
).Returns([]database.PaginatedOrganizationMembersRow{
1003+
{
1004+
OrganizationMember:mem,
1005+
Username:u.Username,
1006+
AvatarURL:u.AvatarURL,
1007+
Name:u.Name,
1008+
Email:u.Email,
1009+
GlobalRoles:u.RBACRoles,
1010+
Count:1,
1011+
},
1012+
})
1013+
}))
9881014
s.Run("UpdateMemberRoles",s.Subtest(func(db database.Store,check*expects) {
9891015
o:=dbgen.Organization(s.T(),db, database.Organization{})
9901016
u:=dbgen.User(s.T(),db, database.User{})

‎coderd/database/dbauthz/setup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func asserts(inputs ...any) []AssertRBAC {
503503
// Could be the string type.
504504
actionAsString,ok:=inputs[i+1].(string)
505505
if!ok {
506-
panic(fmt.Sprintf("action '%q' not a supported action",actionAsString))
506+
panic(fmt.Sprintf("action '%T' not a supported action",inputs[i+1]))
507507
}
508508
action=policy.Action(actionAsString)
509509
}

‎coderd/database/dbmem/dbmem.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9617,6 +9617,53 @@ func (q *FakeQuerier) OrganizationMembers(_ context.Context, arg database.Organi
96179617
returntmp,nil
96189618
}
96199619

9620+
func (q*FakeQuerier)PaginatedOrganizationMembers(_ context.Context,arg database.PaginatedOrganizationMembersParams) ([]database.PaginatedOrganizationMembersRow,error) {
9621+
err:=validateDatabaseType(arg)
9622+
iferr!=nil {
9623+
returnnil,err
9624+
}
9625+
9626+
q.mutex.RLock()
9627+
deferq.mutex.RUnlock()
9628+
9629+
// All of the members in the organization
9630+
orgMembers:=make([]database.OrganizationMember,0)
9631+
for_,mem:=rangeq.organizationMembers {
9632+
ifarg.OrganizationID!=uuid.Nil&&mem.OrganizationID!=arg.OrganizationID {
9633+
continue
9634+
}
9635+
9636+
orgMembers=append(orgMembers,mem)
9637+
}
9638+
9639+
selectedMembers:=make([]database.PaginatedOrganizationMembersRow,0)
9640+
9641+
skippedMembers:=0
9642+
for_,organizationMember:=rangeq.organizationMembers {
9643+
ifskippedMembers<int(arg.OffsetOpt) {
9644+
skippedMembers++
9645+
continue
9646+
}
9647+
9648+
// if the limit is set to 0 we treat that as returning all of the org members
9649+
ifint(arg.LimitOpt)!=0&&len(selectedMembers)>=int(arg.LimitOpt) {
9650+
break
9651+
}
9652+
9653+
user,_:=q.getUserByIDNoLock(organizationMember.UserID)
9654+
selectedMembers=append(selectedMembers, database.PaginatedOrganizationMembersRow{
9655+
OrganizationMember:organizationMember,
9656+
Username:user.Username,
9657+
AvatarURL:user.AvatarURL,
9658+
Name:user.Name,
9659+
Email:user.Email,
9660+
GlobalRoles:user.RBACRoles,
9661+
Count:int64(len(orgMembers)),
9662+
})
9663+
}
9664+
returnselectedMembers,nil
9665+
}
9666+
96209667
func (q*FakeQuerier)ReduceWorkspaceAgentShareLevelToAuthenticatedByTemplate(_ context.Context,templateID uuid.UUID)error {
96219668
err:=validateDatabaseType(templateID)
96229669
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp