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

Commit2984d4e

Browse files
committed
feat(agent/agentcontainers): refactor Lister to ContainerCLI and implement new methods
This change redefines the Lister interface and implements new methodsneeded for sub agent injection.Updatescoder/internal#621
1 parent2e621a7 commit2984d4e

File tree

10 files changed

+238
-95
lines changed

10 files changed

+238
-95
lines changed

‎agent/agentcontainers/acmock/acmock.go

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

‎agent/agentcontainers/acmock/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Package acmock contains a mock implementation of agentcontainers.Lister for use in tests.
22
package acmock
33

4-
//go:generate mockgen -destination ./acmock.go -package acmock ..Lister,DevcontainerCLI
4+
//go:generate mockgen -destination ./acmock.go -package acmock ..ContainerCLI,DevcontainerCLI

‎agent/agentcontainers/api.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type API struct {
4343
logger slog.Logger
4444
watcher watcher.Watcher
4545
execer agentexec.Execer
46-
clLister
46+
ccliContainerCLI
4747
dccliDevcontainerCLI
4848
clock quartz.Clock
4949
scriptLoggerfunc(logSourceID uuid.UUID)ScriptLogger
@@ -80,11 +80,11 @@ func WithExecer(execer agentexec.Execer) Option {
8080
}
8181
}
8282

83-
//WithLister sets the agentcontainers.Lister implementation to use.
84-
// The default implementation uses the Docker CLI to list containers.
85-
funcWithLister(clLister)Option {
83+
//WithContainerCLI sets the agentcontainers.ContainerCLI implementation
84+
//to use.The default implementation uses the Docker CLI.
85+
funcWithContainerCLI(ccliContainerCLI)Option {
8686
returnfunc(api*API) {
87-
api.cl=cl
87+
api.ccli=ccli
8888
}
8989
}
9090

@@ -186,8 +186,8 @@ func NewAPI(logger slog.Logger, options ...Option) *API {
186186
for_,opt:=rangeoptions {
187187
opt(api)
188188
}
189-
ifapi.cl==nil {
190-
api.cl=NewDocker(api.execer)
189+
ifapi.ccli==nil {
190+
api.ccli=NewDockerCLI(api.execer)
191191
}
192192
ifapi.dccli==nil {
193193
api.dccli=NewDevcontainerCLI(logger.Named("devcontainer-cli"),api.execer)
@@ -363,7 +363,7 @@ func (api *API) updateContainers(ctx context.Context) error {
363363
listCtx,listCancel:=context.WithTimeout(ctx,listContainersTimeout)
364364
deferlistCancel()
365365

366-
updated,err:=api.cl.List(listCtx)
366+
updated,err:=api.ccli.List(listCtx)
367367
iferr!=nil {
368368
// If the context was canceled, we hold off on clearing the
369369
// containers cache. This is to avoid clearing the cache if

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp