summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorNicolas De Loof <nicolas.deloof@gmail.com>2022-10-26 18:13:17 +0200
committerPaweł Gronowski <pawel.gronowski@docker.com>2022-11-03 12:22:40 +0100
commitdef549c8f6716507ee9175fe9d798a42df89e27d (patch)
treec186438bd725949129767e875b589e8130836f05 /api
parent4c07d585926dbc06ce9623dd83c8e2a7ee48289d (diff)
downloaddocker-def549c8f6716507ee9175fe9d798a42df89e27d.tar.gz
imageservice: Add context to various methods
Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Diffstat (limited to 'api')
-rw-r--r--api/server/router/container/backend.go8
-rw-r--r--api/server/router/container/container_routes.go8
-rw-r--r--api/server/router/image/backend.go2
-rw-r--r--api/server/router/image/image_routes.go2
-rw-r--r--api/server/router/swarm/backend.go2
-rw-r--r--api/server/router/swarm/cluster_routes.go2
6 files changed, 12 insertions, 12 deletions
diff --git a/api/server/router/container/backend.go b/api/server/router/container/backend.go
index 4db989a102..f0624eef83 100644
--- a/api/server/router/container/backend.go
+++ b/api/server/router/container/backend.go
@@ -32,14 +32,14 @@ type copyBackend interface {
// stateBackend includes functions to implement to provide container state lifecycle functionality.
type stateBackend interface {
- ContainerCreate(config types.ContainerCreateConfig) (container.CreateResponse, error)
+ ContainerCreate(ctx context.Context, config types.ContainerCreateConfig) (container.CreateResponse, error)
ContainerKill(name string, signal string) error
ContainerPause(name string) error
ContainerRename(oldName, newName string) error
ContainerResize(name string, height, width int) error
ContainerRestart(ctx context.Context, name string, options container.StopOptions) error
ContainerRm(name string, config *types.ContainerRmConfig) error
- ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
+ ContainerStart(ctx context.Context, name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
ContainerStop(ctx context.Context, name string, options container.StopOptions) error
ContainerUnpause(name string) error
ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error)
@@ -54,7 +54,7 @@ type monitorBackend interface {
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)
- Containers(config *types.ContainerListOptions) ([]*types.Container, error)
+ Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error)
}
// attachBackend includes function to implement to provide container attaching functionality.
@@ -68,7 +68,7 @@ type systemBackend interface {
}
type commitBackend interface {
- CreateImageFromContainer(name string, config *backend.CreateImageConfig) (imageID string, err error)
+ CreateImageFromContainer(ctx context.Context, name string, config *backend.CreateImageConfig) (imageID string, err error)
}
// Backend is all the methods that need to be implemented to provide container specific functionality.
diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go
index 6670b9ec68..5df051fc95 100644
--- a/api/server/router/container/container_routes.go
+++ b/api/server/router/container/container_routes.go
@@ -58,7 +58,7 @@ func (s *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter,
Changes: r.Form["changes"],
}
- imgID, err := s.backend.CreateImageFromContainer(r.Form.Get("container"), commitCfg)
+ imgID, err := s.backend.CreateImageFromContainer(ctx, r.Form.Get("container"), commitCfg)
if err != nil {
return err
}
@@ -91,7 +91,7 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response
config.Limit = limit
}
- containers, err := s.backend.Containers(config)
+ containers, err := s.backend.Containers(ctx, config)
if err != nil {
return err
}
@@ -214,7 +214,7 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon
checkpoint := r.Form.Get("checkpoint")
checkpointDir := r.Form.Get("checkpoint-dir")
- if err := s.backend.ContainerStart(vars["name"], hostConfig, checkpoint, checkpointDir); err != nil {
+ if err := s.backend.ContainerStart(ctx, vars["name"], hostConfig, checkpoint, checkpointDir); err != nil {
return err
}
@@ -578,7 +578,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
hostConfig.PidsLimit = nil
}
- ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
+ ccr, err := s.backend.ContainerCreate(ctx, types.ContainerCreateConfig{
Name: name,
Config: config,
HostConfig: hostConfig,
diff --git a/api/server/router/image/backend.go b/api/server/router/image/backend.go
index 71261f06b4..7003dfc67e 100644
--- a/api/server/router/image/backend.go
+++ b/api/server/router/image/backend.go
@@ -31,7 +31,7 @@ type imageBackend interface {
type importExportBackend interface {
LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error
- ImportImage(src string, repository string, platform *specs.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
+ ImportImage(ctx context.Context, src string, repository string, platform *specs.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
ExportImage(ctx context.Context, names []string, outStream io.Writer) error
}
diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go
index 724e4e18c6..52a4b5e95c 100644
--- a/api/server/router/image/image_routes.go
+++ b/api/server/router/image/image_routes.go
@@ -68,7 +68,7 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
progressErr = ir.backend.PullImage(ctx, img, tag, platform, metaHeaders, authConfig, output)
} else { // import
src := r.Form.Get("fromSrc")
- progressErr = ir.backend.ImportImage(src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
+ progressErr = ir.backend.ImportImage(ctx, src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
}
if progressErr != nil {
if !output.Flushed() {
diff --git a/api/server/router/swarm/backend.go b/api/server/router/swarm/backend.go
index d0c7e60fb3..fa63e363bd 100644
--- a/api/server/router/swarm/backend.go
+++ b/api/server/router/swarm/backend.go
@@ -12,7 +12,7 @@ import (
type Backend interface {
Init(req types.InitRequest) (string, error)
Join(req types.JoinRequest) error
- Leave(force bool) error
+ Leave(ctx context.Context, force bool) error
Inspect() (types.Swarm, error)
Update(uint64, types.Spec, types.UpdateFlags) error
GetUnlockKey() (string, error)
diff --git a/api/server/router/swarm/cluster_routes.go b/api/server/router/swarm/cluster_routes.go
index 293e4f1421..8a77e300d6 100644
--- a/api/server/router/swarm/cluster_routes.go
+++ b/api/server/router/swarm/cluster_routes.go
@@ -56,7 +56,7 @@ func (sr *swarmRouter) leaveCluster(ctx context.Context, w http.ResponseWriter,
}
force := httputils.BoolValue(r, "force")
- return sr.backend.Leave(force)
+ return sr.backend.Leave(ctx, force)
}
func (sr *swarmRouter) inspectCluster(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {