client

package
v0.0.0-...-1012304 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDockerHost = "unix:///var/run/prizes.sock"

DefaultDockerHost defines os specific default if DOCKER_HOST is unset

Variables

View Source
var ErrRedirect = errors.New("unexpected redirect in response")

ErrRedirect is the error returned by checkRedirect when the request is non-GET.

Functions

func CheckRedirect

func CheckRedirect(req *http.Request, via []*http.Request) error

CheckRedirect specifies the policy for dealing with redirect responses: If the request is non-GET return `ErrRedirect`. Otherwise use the last response.

Go 1.8 changes behavior for HTTP redirects (specifically 301, 307, and 308) in the client . The Docker client (and by extension docker API client) can be made to send a request like POST /containers//start where what would normally be in the name section of the URL is empty. This triggers an HTTP 301 from the daemon. In go 1.8 this 301 will be converted to a GET request, and ends up getting a 404 from the daemon. This behavior change manifests in the client in that before the 301 was not followed and the client did not generate an error, but now results in a message like Error response from daemon: page not found.

func ParseHostURL

func ParseHostURL(host string) (*url.URL, error)

ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the API client that performs all operations against a docker server.

func NewClientWithOpts

func NewClientWithOpts() (*Client, error)

NewClientWithOpts initializes a new API client with default values. It takes functors to modify values when creating it, like `NewClientWithOpts(WithVersion(…))` It also initializes the custom http headers to add to each request.

It won't send any version information if the version number is empty. It is highly recommended that you set a version or your client may break if the server is upgraded.

func (*Client) ClientVersion

func (cli *Client) ClientVersion() string

ClientVersion returns the API version used by this client.

func (*Client) Close

func (cli *Client) Close() error

Close the transport used by the client

func (*Client) CustomHTTPHeaders

func (cli *Client) CustomHTTPHeaders() map[string]string

CustomHTTPHeaders returns the custom http headers stored by the client.

func (*Client) DaemonHost

func (cli *Client) DaemonHost() string

DaemonHost returns the host address used by the client

func (*Client) Dialer

func (cli *Client) Dialer() func(context.Context) (net.Conn, error)

Dialer returns a dialer for a raw stream connection, with HTTP/1.1 header, that can be used for proxying the daemon connection. Used by `docker dial-stdio` (docker/cli#889).

func (*Client) HTTPClient

func (cli *Client) HTTPClient() *http.Client

HTTPClient returns a copy of the HTTP client bound to the server

func (*Client) NegotiateAPIVersionPing

func (cli *Client) NegotiateAPIVersionPing(p types.Ping)

NegotiateAPIVersionPing updates the client version to match the Ping.APIVersion if the ping version is less than the default version. If a manual override is in place, either through the `DOCKER_API_VERSION` environment variable, or if the client was initialized with a fixed version (`opts.WithVersion(xx)`), no negotiation is performed.

func (*Client) SetCustomHTTPHeaders

func (cli *Client) SetCustomHTTPHeaders(headers map[string]string)

SetCustomHTTPHeaders that will be set on every HTTP request made by the client. Deprecated: use WithHTTPHeaders when creating the client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL