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

Commit0e568fb

Browse files
committed
fix copilot nits
1 parenta997f82 commit0e568fb

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

‎agent/agent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,9 @@ func (a *agent) createTailnet(
14821482
iferr=a.trackGoroutine(func() {
14831483
deferapiListener.Close()
14841484
apiHandler,closeAPIHAndler:=a.apiHandler()
1485+
deferfunc() {
1486+
_=closeAPIHAndler()
1487+
}()
14851488
server:=&http.Server{
14861489
BaseContext:func(net.Listener) context.Context {returnctx },
14871490
Handler:apiHandler,

‎agent/agentcontainers/api.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ type API struct {
4545

4646
// lockCh protects the below fields. We use a channel instead of a
4747
// mutex so we can handle cancellation properly.
48-
lockChchanstruct{}
49-
containers codersdk.WorkspaceAgentListContainersResponse
50-
mtime time.Time
51-
devcontainerNamesmap[string]struct{}// Track devcontainer names to avoid duplicates.
52-
knownDevcontainers []codersdk.WorkspaceAgentDevcontainer// Track predefined and runtime-detected devcontainers.
53-
configModifiedTimesmap[string]time.Time// Track when config files were last modified.
48+
lockChchanstruct{}
49+
containerscodersdk.WorkspaceAgentListContainersResponse
50+
mtimetime.Time
51+
devcontainerNamesmap[string]struct{}// Track devcontainer names to avoid duplicates.
52+
knownDevcontainers[]codersdk.WorkspaceAgentDevcontainer// Track predefined and runtime-detected devcontainers.
53+
configFileModifiedTimesmap[string]time.Time// Track when config files were last modified.
5454
}
5555

5656
// Option is a functional option for API.
@@ -108,16 +108,16 @@ func WithWatcher(w watcher.Watcher) Option {
108108
funcNewAPI(logger slog.Logger,options...Option)*API {
109109
ctx,cancel:=context.WithCancel(context.Background())
110110
api:=&API{
111-
ctx:ctx,
112-
cancel:cancel,
113-
done:make(chanstruct{}),
114-
logger:logger,
115-
clock:quartz.NewReal(),
116-
cacheDuration:defaultGetContainersCacheDuration,
117-
lockCh:make(chanstruct{},1),
118-
devcontainerNames:make(map[string]struct{}),
119-
knownDevcontainers: []codersdk.WorkspaceAgentDevcontainer{},
120-
configModifiedTimes:make(map[string]time.Time),
111+
ctx:ctx,
112+
cancel:cancel,
113+
done:make(chanstruct{}),
114+
logger:logger,
115+
clock:quartz.NewReal(),
116+
cacheDuration:defaultGetContainersCacheDuration,
117+
lockCh:make(chanstruct{},1),
118+
devcontainerNames:make(map[string]struct{}),
119+
knownDevcontainers:[]codersdk.WorkspaceAgentDevcontainer{},
120+
configFileModifiedTimes:make(map[string]time.Time),
121121
}
122122
for_,opt:=rangeoptions {
123123
opt(api)
@@ -281,7 +281,7 @@ func (api *API) getContainers(ctx context.Context) (codersdk.WorkspaceAgentListC
281281
// Check if this container was created after the config
282282
// file was modified.
283283
ifconfigFile!=""&&api.knownDevcontainers[knownIndex].Dirty {
284-
lastModified,hasModTime:=api.configModifiedTimes[configFile]
284+
lastModified,hasModTime:=api.configFileModifiedTimes[configFile]
285285
ifhasModTime&&container.CreatedAt.After(lastModified) {
286286
api.logger.Info(ctx,"clearing dirty flag for container created after config modification",
287287
slog.F("container",container.ID),
@@ -316,7 +316,7 @@ func (api *API) getContainers(ctx context.Context) (codersdk.WorkspaceAgentListC
316316

317317
dirty:=dirtyStates[workspaceFolder]
318318
ifdirty {
319-
lastModified,hasModTime:=api.configModifiedTimes[configFile]
319+
lastModified,hasModTime:=api.configFileModifiedTimes[configFile]
320320
ifhasModTime&&container.CreatedAt.After(lastModified) {
321321
api.logger.Info(ctx,"new container created after config modification, not marking as dirty",
322322
slog.F("container",container.ID),
@@ -473,7 +473,7 @@ func (api *API) markDevcontainerDirty(configPath string, modifiedAt time.Time) {
473473
}
474474

475475
// Record the timestamp of when this configuration file was modified.
476-
api.configModifiedTimes[configPath]=modifiedAt
476+
api.configFileModifiedTimes[configPath]=modifiedAt
477477

478478
fori:=rangeapi.knownDevcontainers {
479479
ifapi.knownDevcontainers[i].ConfigPath==configPath {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp