Skip to content

Commit

Permalink
misc: add VersionWithContext method
Browse files Browse the repository at this point in the history
In rare cases, Docker's "/version" API might take a long time to
respond. Wrapping this with a context gives clients more control
over handling this scenario.
  • Loading branch information
aaithal committed Apr 24, 2018
1 parent eb4b272 commit ee88dab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: go
sudo: required
go:
- 1.9.x
- 1.10.x
- tip
os:
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ clone_folder: c:\gopath\src\github.com\fsouza\go-dockerclient
environment:
GOPATH: c:\gopath
matrix:
- GOVERSION: 1.9.5
- GOVERSION: 1.10.1
install:
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
Expand Down
8 changes: 7 additions & 1 deletion misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package docker

import (
"context"
"encoding/json"
"net"
"strings"
Expand All @@ -16,7 +17,12 @@ import (
//
// See https://goo.gl/mU7yje for more details.
func (c *Client) Version() (*Env, error) {
resp, err := c.do("GET", "/version", doOptions{})
return c.VersionWithContext(nil)
}

// VersionWithContext returns version information about the docker server.
func (c *Client) VersionWithContext(ctx context.Context) (*Env, error) {
resp, err := c.do("GET", "/version", doOptions{context: ctx})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ee88dab

Please sign in to comment.