summaryrefslogtreecommitdiff
path: root/vendor/github.com/fsouza/go-dockerclient/container_kill.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-29 18:15:24 +0100
committerGitHub <noreply@github.com>2020-10-29 18:15:24 +0100
commitc8f0e1dab602ed94af95dc4f604f161696f249e0 (patch)
tree1d8fe4e091300aa7c2c6e61fcb1a509c382974b0 /vendor/github.com/fsouza/go-dockerclient/container_kill.go
parente439aec4fa867cda0672079dac0fe394dfb3306c (diff)
parent65a618886efc48562e5b9ff99ca630c83622419b (diff)
downloadpodman-c8f0e1dab602ed94af95dc4f604f161696f249e0.tar.gz
podman-c8f0e1dab602ed94af95dc4f604f161696f249e0.tar.bz2
podman-c8f0e1dab602ed94af95dc4f604f161696f249e0.zip
Merge pull request #8146 from vrothberg/image-mounts
new "image" mount type
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/container_kill.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/container_kill.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/container_kill.go b/vendor/github.com/fsouza/go-dockerclient/container_kill.go
new file mode 100644
index 000000000..ee9f0418f
--- /dev/null
+++ b/vendor/github.com/fsouza/go-dockerclient/container_kill.go
@@ -0,0 +1,45 @@
+package docker
+
+import (
+ "context"
+ "net/http"
+)
+
+// KillContainerOptions represents the set of options that can be used in a
+// call to KillContainer.
+//
+// See https://goo.gl/JnTxXZ for more details.
+type KillContainerOptions struct {
+ // The ID of the container.
+ ID string `qs:"-"`
+
+ // The signal to send to the container. When omitted, Docker server
+ // will assume SIGKILL.
+ Signal Signal
+ Context context.Context
+}
+
+// KillContainer sends a signal to a container, returning an error in case of
+// failure.
+//
+// See https://goo.gl/JnTxXZ for more details.
+func (c *Client) KillContainer(opts KillContainerOptions) error {
+ path := "/containers/" + opts.ID + "/kill" + "?" + queryString(opts)
+ resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
+ if err != nil {
+ e, ok := err.(*Error)
+ if !ok {
+ return err
+ }
+ switch e.Status {
+ case http.StatusNotFound:
+ return &NoSuchContainer{ID: opts.ID}
+ case http.StatusConflict:
+ return &ContainerNotRunning{ID: opts.ID}
+ default:
+ return err
+ }
+ }
+ resp.Body.Close()
+ return nil
+}