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

Commit8353313

Browse files
committed
revert non-test files
1 parentc5ea297 commit8353313

File tree

14 files changed

+74
-14
lines changed

14 files changed

+74
-14
lines changed

‎agent/agent.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26
547547
// channel to synchronize the results and avoid both messy
548548
// mutex logic and overloading the API.
549549
for_,md:=rangemanifest.Metadata {
550+
md:=md
550551
// We send the result to the channel in the goroutine to avoid
551552
// sending the same result multiple times. So, we don't care about
552553
// the return values.
@@ -1296,6 +1297,7 @@ func (a *agent) updateCommandEnv(current []string) (updated []string, err error)
12961297
"CODER":"true",
12971298
"CODER_WORKSPACE_NAME":manifest.WorkspaceName,
12981299
"CODER_WORKSPACE_AGENT_NAME":manifest.AgentName,
1300+
"CODER_WORKSPACE_OWNER_NAME":manifest.OwnerName,
12991301

13001302
// Specific Coder subcommands require the agent token exposed!
13011303
"CODER_AGENT_TOKEN":*a.sessionToken.Load(),

‎agent/agentscripts/agentscripts.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S
177177
ifscript.Cron=="" {
178178
continue
179179
}
180+
script:=script
180181
_,err:=r.cron.AddFunc(script.Cron,func() {
181182
err:=r.trackRun(r.cronCtx,script.WorkspaceAgentScript,ExecuteCronScripts)
182183
iferr!=nil {
@@ -253,6 +254,7 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error {
253254
continue
254255
}
255256

257+
script:=script
256258
eg.Go(func()error {
257259
err:=r.trackRun(ctx,script.WorkspaceAgentScript,option)
258260
iferr!=nil {

‎cli/organizationroles.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ func applyOrgResourceActions(role *codersdk.Role, resource string, actions []str
435435
// Construct new site perms with only new perms for the resource
436436
keep:=make([]codersdk.Permission,0)
437437
for_,perm:=rangerole.OrganizationPermissions {
438+
perm:=perm
438439
ifstring(perm.ResourceType)!=resource {
439440
keep=append(keep,perm)
440441
}

‎cli/organizationsettings.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti
116116
}
117117

118118
for_,set:=rangesettings {
119+
set:=set
119120
patch:=set.Patch
120121
cmd.Children=append(cmd.Children,&serpent.Command{
121122
Use:set.Name,
@@ -191,6 +192,7 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett
191192
}
192193

193194
for_,set:=rangesettings {
195+
set:=set
194196
fetch:=set.Fetch
195197
cmd.Children=append(cmd.Children,&serpent.Command{
196198
Use:set.Name,

‎cli/server.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
12021202
varwg sync.WaitGroup
12031203
fori,provisionerDaemon:=rangeprovisionerDaemons {
12041204
id:=i+1
1205+
provisionerDaemon:=provisionerDaemon
12051206
wg.Add(1)
12061207
gofunc() {
12071208
deferwg.Done()
@@ -1679,6 +1680,7 @@ func configureServerTLS(ctx context.Context, logger slog.Logger, tlsMinVersion,
16791680

16801681
// Expensively check which certificate matches the client hello.
16811682
for_,cert:=rangecerts {
1683+
cert:=cert
16821684
iferr:=hi.SupportsCertificate(&cert);err==nil {
16831685
return&cert,nil
16841686
}
@@ -2310,19 +2312,20 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d
23102312

23112313
varerrerror
23122314
varsqlDB*sql.DB
2315+
dbNeedsClosing:=true
23132316
// Try to connect for 30 seconds.
23142317
ctx,cancel:=context.WithTimeout(ctx,30*time.Second)
23152318
defercancel()
23162319

23172320
deferfunc() {
2318-
iferr==nil {
2321+
if!dbNeedsClosing {
23192322
return
23202323
}
23212324
ifsqlDB!=nil {
23222325
_=sqlDB.Close()
23232326
sqlDB=nil
2327+
logger.Debug(ctx,"closed db before returning from ConnectToPostgres")
23242328
}
2325-
logger.Error(ctx,"connect to postgres failed",slog.Error(err))
23262329
}()
23272330

23282331
vartriesint
@@ -2358,11 +2361,8 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d
23582361
returnnil,xerrors.Errorf("get postgres version: %w",err)
23592362
}
23602363
deferversion.Close()
2361-
ifversion.Err()!=nil {
2362-
returnnil,xerrors.Errorf("version select: %w",version.Err())
2363-
}
23642364
if!version.Next() {
2365-
returnnil,xerrors.Errorf("no rows returned for version select")
2365+
returnnil,xerrors.Errorf("no rows returned for version select: %w",version.Err())
23662366
}
23672367
varversionNumint
23682368
err=version.Scan(&versionNum)
@@ -2404,6 +2404,7 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d
24042404
// of connection churn.
24052405
sqlDB.SetMaxIdleConns(3)
24062406

2407+
dbNeedsClosing=false
24072408
returnsqlDB,nil
24082409
}
24092410

‎coderd/database/pubsub/pubsub_memory.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func (m *MemoryPubsub) Publish(event string, message []byte) error {
7373
varwg sync.WaitGroup
7474
for_,listener:=rangelisteners {
7575
wg.Add(1)
76+
listener:=listener
7677
gofunc() {
7778
deferwg.Done()
7879
listener.send(context.Background(),message)

‎coderd/externalauth/externalauth.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut
505505
ids:=map[string]struct{}{}
506506
configs:= []*Config{}
507507
for_,entry:=rangeentries {
508+
entry:=entry
509+
508510
// Applies defaults to the config entry.
509511
// This allows users to very simply state that they type is "GitHub",
510512
// apply their client secret and ID, and have the UI appear nicely.

‎coderd/idpsync/group.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat
9999
// membership via the groups the user is in.
100100
userOrgs:=make(map[uuid.UUID][]database.GetGroupsRow)
101101
for_,g:=rangeuserGroups {
102+
g:=g
102103
userOrgs[g.Group.OrganizationID]=append(userOrgs[g.Group.OrganizationID],g)
103104
}
104105

@@ -336,6 +337,8 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai
336337

337338
groups:=make([]ExpectedGroup,0)
338339
for_,group:=rangeparsedGroups {
340+
group:=group
341+
339342
// Legacy group mappings happen before the regex filter.
340343
mappedGroupName,ok:=s.LegacyNameMapping[group]
341344
ifok {
@@ -352,6 +355,7 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai
352355
mappedGroupIDs,ok:=s.Mapping[group]
353356
ifok {
354357
for_,gid:=rangemappedGroupIDs {
358+
gid:=gid
355359
groups=append(groups,ExpectedGroup{OrganizationID:orgID,GroupID:&gid})
356360
}
357361
continue

‎coderd/rbac/authz.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ func rbacTraceAttributes(actor Subject, action policy.Action, objectType string,
760760
uniqueRoleNames:=actor.SafeRoleNames()
761761
roleStrings:=make([]string,0,len(uniqueRoleNames))
762762
for_,roleName:=rangeuniqueRoleNames {
763+
roleName:=roleName
763764
roleStrings=append(roleStrings,roleName.String())
764765
}
765766
returntrace.WithAttributes(

‎coderd/rbac/roles.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,15 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
270270
Site:append(
271271
// Workspace dormancy and workspace are omitted.
272272
// Workspace is specifically handled based on the opts.NoOwnerWorkspaceExec
273-
allPermsExcept(ResourceWorkspaceDormant,ResourceWorkspace),
273+
allPermsExcept(ResourceWorkspaceDormant,ResourcePrebuiltWorkspace,ResourceWorkspace),
274274
// This adds back in the Workspace permissions.
275275
Permissions(map[string][]policy.Action{
276276
ResourceWorkspace.Type:ownerWorkspaceActions,
277277
ResourceWorkspaceDormant.Type: {policy.ActionRead,policy.ActionDelete,policy.ActionCreate,policy.ActionUpdate,policy.ActionWorkspaceStop,policy.ActionCreateAgent,policy.ActionDeleteAgent},
278+
// PrebuiltWorkspaces are a subset of Workspaces.
279+
// Explicitly setting PrebuiltWorkspace permissions for clarity.
280+
// Note: even without PrebuiltWorkspace permissions, access is still granted via Workspace permissions.
281+
ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate,policy.ActionDelete},
278282
})...),
279283
Org:map[string][]Permission{},
280284
User: []Permission{},
@@ -290,7 +294,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
290294
ResourceWorkspaceProxy.Type: {policy.ActionRead},
291295
}),
292296
Org:map[string][]Permission{},
293-
User:append(allPermsExcept(ResourceWorkspaceDormant,ResourceUser,ResourceOrganizationMember),
297+
User:append(allPermsExcept(ResourceWorkspaceDormant,ResourcePrebuiltWorkspace,ResourceUser,ResourceOrganizationMember),
294298
Permissions(map[string][]policy.Action{
295299
// Reduced permission set on dormant workspaces. No build, ssh, or exec
296300
ResourceWorkspaceDormant.Type: {policy.ActionRead,policy.ActionDelete,policy.ActionCreate,policy.ActionUpdate,policy.ActionWorkspaceStop,policy.ActionCreateAgent,policy.ActionDeleteAgent},
@@ -335,8 +339,9 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
335339
ResourceAssignOrgRole.Type: {policy.ActionRead},
336340
ResourceTemplate.Type:ResourceTemplate.AvailableActions(),
337341
// CRUD all files, even those they did not upload.
338-
ResourceFile.Type: {policy.ActionCreate,policy.ActionRead},
339-
ResourceWorkspace.Type: {policy.ActionRead},
342+
ResourceFile.Type: {policy.ActionCreate,policy.ActionRead},
343+
ResourceWorkspace.Type: {policy.ActionRead},
344+
ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate,policy.ActionDelete},
340345
// CRUD to provisioner daemons for now.
341346
ResourceProvisionerDaemon.Type: {policy.ActionCreate,policy.ActionRead,policy.ActionUpdate,policy.ActionDelete},
342347
// Needs to read all organizations since
@@ -413,9 +418,13 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
413418
}),
414419
Org:map[string][]Permission{
415420
// Org admins should not have workspace exec perms.
416-
organizationID.String():append(allPermsExcept(ResourceWorkspace,ResourceWorkspaceDormant,ResourceAssignRole),Permissions(map[string][]policy.Action{
421+
organizationID.String():append(allPermsExcept(ResourceWorkspace,ResourceWorkspaceDormant,ResourcePrebuiltWorkspace,ResourceAssignRole),Permissions(map[string][]policy.Action{
417422
ResourceWorkspaceDormant.Type: {policy.ActionRead,policy.ActionDelete,policy.ActionCreate,policy.ActionUpdate,policy.ActionWorkspaceStop,policy.ActionCreateAgent,policy.ActionDeleteAgent},
418423
ResourceWorkspace.Type:slice.Omit(ResourceWorkspace.AvailableActions(),policy.ActionApplicationConnect,policy.ActionSSH),
424+
// PrebuiltWorkspaces are a subset of Workspaces.
425+
// Explicitly setting PrebuiltWorkspace permissions for clarity.
426+
// Note: even without PrebuiltWorkspace permissions, access is still granted via Workspace permissions.
427+
ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate,policy.ActionDelete},
419428
})...),
420429
},
421430
User: []Permission{},
@@ -493,9 +502,10 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
493502
Site: []Permission{},
494503
Org:map[string][]Permission{
495504
organizationID.String():Permissions(map[string][]policy.Action{
496-
ResourceTemplate.Type:ResourceTemplate.AvailableActions(),
497-
ResourceFile.Type: {policy.ActionCreate,policy.ActionRead},
498-
ResourceWorkspace.Type: {policy.ActionRead},
505+
ResourceTemplate.Type:ResourceTemplate.AvailableActions(),
506+
ResourceFile.Type: {policy.ActionCreate,policy.ActionRead},
507+
ResourceWorkspace.Type: {policy.ActionRead},
508+
ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate,policy.ActionDelete},
499509
// Assigning template perms requires this permission.
500510
ResourceOrganization.Type: {policy.ActionRead},
501511
ResourceOrganizationMember.Type: {policy.ActionRead},
@@ -837,6 +847,7 @@ func Permissions(perms map[string][]policy.Action) []Permission {
837847
list:=make([]Permission,0,len(perms))
838848
fork,actions:=rangeperms {
839849
for_,act:=rangeactions {
850+
act:=act
840851
list=append(list,Permission{
841852
Negate:false,
842853
ResourceType:k,

‎coderd/webpush/webpush.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func (n *Webpusher) Dispatch(ctx context.Context, userID uuid.UUID, msg codersdk
103103
varmu sync.Mutex
104104
vareg errgroup.Group
105105
for_,subscription:=rangesubscriptions {
106+
subscription:=subscription
106107
eg.Go(func()error {
107108
// TODO: Implement some retry logic here. For now, this is just a
108109
// best-effort attempt.

‎enterprise/coderd/proxyhealth/proxyhealth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID
240240
}
241241
// Each proxy needs to have a status set. Make a local copy for the
242242
// call to be run async.
243+
proxy:=proxy
243244
status:=ProxyStatus{
244245
Proxy:proxy,
245246
CheckedAt:now,

‎enterprise/replicasync/replicasync.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ func (m *Manager) AllPrimary() []database.Replica {
408408
continue
409409
}
410410

411+
// When we assign the non-pointer to a
412+
// variable it loses the reference.
413+
replica:=replica
411414
replicas=append(replicas,replica)
412415
}
413416
returnreplicas

‎site/site.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Options struct {
8585
Entitlements*entitlements.Set
8686
Telemetry telemetry.Reporter
8787
Logger slog.Logger
88+
HideAITasksbool
8889
}
8990

9091
funcNew(opts*Options)*Handler {
@@ -316,6 +317,8 @@ type htmlState struct {
316317
Experimentsstring
317318
Regionsstring
318319
DocsURLstring
320+
321+
TasksTabVisiblestring
319322
}
320323

321324
typecsrfStatestruct {
@@ -445,6 +448,7 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
445448
varuser database.User
446449
varthemePreferencestring
447450
varterminalFontstring
451+
vartasksTabVisiblebool
448452
orgIDs:= []uuid.UUID{}
449453
eg.Go(func()error {
450454
varerrerror
@@ -480,6 +484,20 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
480484
orgIDs=memberIDs[0].OrganizationIDs
481485
returnerr
482486
})
487+
eg.Go(func()error {
488+
// If HideAITasks is true, force hide the tasks tab
489+
ifh.opts.HideAITasks {
490+
tasksTabVisible=false
491+
returnnil
492+
}
493+
494+
hasAITask,err:=h.opts.Database.HasTemplateVersionsWithAITask(ctx)
495+
iferr!=nil {
496+
returnerr
497+
}
498+
tasksTabVisible=hasAITask
499+
returnnil
500+
})
483501
err:=eg.Wait()
484502
iferr==nil {
485503
varwg sync.WaitGroup
@@ -550,6 +568,14 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht
550568
}
551569
}()
552570
}
571+
wg.Add(1)
572+
gofunc() {
573+
deferwg.Done()
574+
tasksTabVisible,err:=json.Marshal(tasksTabVisible)
575+
iferr==nil {
576+
state.TasksTabVisible=html.EscapeString(string(tasksTabVisible))
577+
}
578+
}()
553579
wg.Wait()
554580
}
555581

@@ -823,6 +849,8 @@ func verifyBinSha1IsCurrent(dest string, siteFS fs.FS, shaFiles map[string]strin
823849

824850
// Verify the hash of each on-disk binary.
825851
forfile,hash1:=rangeshaFiles {
852+
file:=file
853+
hash1:=hash1
826854
eg.Go(func()error {
827855
hash2,err:=sha1HashFile(filepath.Join(dest,file))
828856
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp