Browse code

client: ContainerKill(): don't send signal query-param if none was set

Just a small clean-up (there's more endpoints to do this for, but
I was working on changes in this area on the CLI when I noticed we
were setting this query-parameter unconditionally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2022/04/20 00:40:33
Showing 1 changed files
... ...
@@ -8,7 +8,9 @@ import (
8 8
 // ContainerKill terminates the container process but does not remove the container from the docker host.
9 9
 func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error {
10 10
 	query := url.Values{}
11
-	query.Set("signal", signal)
11
+	if signal != "" {
12
+		query.Set("signal", signal)
13
+	}
12 14
 
13 15
 	resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil)
14 16
 	ensureReaderClosed(resp)