Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
GSeibt committed Jul 1, 2020
1 parent f7b4352 commit a0ff4b1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sdk/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func (h *Handler) Serve(l net.Listener) error {
return server.Serve(l)
}

// Gracefully shuts down the http.Server serving requests
// Shutdown gracefully shuts down the http.Server serving requests after Serve or
// Serve{TCP,Unix,Windows} was called.
func (h *Handler) Shutdown(c context.Context) error {
return h.server.Shutdown(c)
}
Expand Down
6 changes: 6 additions & 0 deletions sdk/tcp_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
"github.com/docker/go-connections/sockets"
)

// NewTCPListener constructs a net.Listener to use for serving requests at the given TCP address.
// It also writes the spec file in the right directory for docker to read.
//
// Due to constrains for running Docker in Docker on Windows, data-root directory
// of docker daemon must be provided. To get default directory, use
// WindowsDefaultDaemonRootDir() function. On Unix, this parameter is ignored.
func NewTCPListener(address, pluginName, daemonDir string, tlsConfig *tls.Config) (net.Listener, string, error) {
listener, err := sockets.NewTCPSocket(address, tlsConfig)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions sdk/unix_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

const pluginSockDir = "/run/docker/plugins"

// NewUnixListener constructs a net.Listener to use for serving requests at the given unix socket.
// It also creates the socket file in the right directory for docker to read.
func NewUnixListener(pluginName string, gid int) (net.Listener, string, error) {
path, err := fullSocketAddress(pluginName)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions sdk/windows_listener_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ var (
errOnlySupportedOnWindows = errors.New("named pipe creation is only supported on Windows")
)

// NewWindowsListener constructs a net.Listener to use for serving requests at the given Windows named pipe.
// It also creates the spec file in the right directory for docker to read.
//
// Due to constrains for running Docker in Docker on Windows, the data-root directory
// of docker daemon must be provided. To get default directory, use
// WindowsDefaultDaemonRootDir() function. On Unix, this parameter is ignored.
func NewWindowsListener(address, pluginName, daemonRoot string, pipeConfig *WindowsPipeConfig) (net.Listener, string, error) {
return nil, "", errOnlySupportedOnWindows
}
Expand Down

0 comments on commit a0ff4b1

Please sign in to comment.