proxy

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DOCKER_SOCKET = "/var/run/docker.sock"
	PROXY_SOCKET  = "/tmp/doxy.sock"
	PATTERN_FILE  = "/etc/doxy.pattern"
	DEVICE_FILE   = "/etc/doxy.devices"
)

Variables

View Source
var (
	DEF_PAT = []string{
		`^/(v\d\.\d+/)?containers(/\w+)?/(json|stats|top)$`,
		`^/(v\d\.\d+/)?services(/[0-9a-f]+)?$`,
		`^/(v\d\.\d+/)?tasks(/\w+)?$`,
		`^/(v\d\.\d+/)?networks(/\w+)?$`,
		`^/(v\d\.\d+/)?volumes(/\w+)?$`,
		`^/(v\d\.\d+/)?nodes(/\w+)?$`,
		`^/(v\d\.\d+/)?info$`,
		`^/(v\d\.\d+/)?version$`,
		"^/_ping$",
	}
	HPC_PAT = []string{
		`^/(v\d\.\d+/)?containers(/\w+)?/(json|stats|top|logs|wait|create|start|run|kill)$`,
		`^/(v\d\.\d+/)?images(/\w+)?/(json|pull|create)$`,
		`^/(v\d\.\d+/)?info$`,
		`^/(v\d\.\d+/)?images/(pull|create)$`,
		`^/(v\d\.\d+/)?version$`,
		"^/_ping$",
	}
	GPUS = []string{
		"/dev/nvidia0:/dev/nvidia0:rwm",
		"/dev/nvidiactl:/dev/nvidiactl:rwm",
	}
	PATTERNS = map[string][]string{
		"default": DEF_PAT,
		"hpc":     HPC_PAT,
	}
)

Functions

func ListenToNewSock

func ListenToNewSock(newsock string, sigc chan os.Signal) (l net.Listener, err error)

func ReadLineFile added in v0.2.1

func ReadLineFile(reader io.Reader) (patterns []string, err error)

Types

type Headers added in v0.2.0

type Headers map[string][]string

type Proxy

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

func NewProxy

func NewProxy(opts ...ProxyOption) Proxy

func (*Proxy) GetOptions added in v0.1.2

func (p *Proxy) GetOptions() map[string]interface{}

func (*Proxy) Run

func (p *Proxy) Run()

type ProxyOption added in v0.1.2

type ProxyOption func(*ProxyOptions)

func WithBindMounts added in v0.2.0

func WithBindMounts(bm []string) ProxyOption

func WithCudaLibPath added in v0.2.5

func WithCudaLibPath(s string) ProxyOption

func WithDebugEnabled added in v0.1.2

func WithDebugEnabled() ProxyOption

func WithDebugValue added in v0.1.2

func WithDebugValue(d bool) ProxyOption

func WithDevMappings added in v0.2.0

func WithDevMappings(dm []string) ProxyOption

func WithDockerSocket added in v0.1.2

func WithDockerSocket(s string) ProxyOption

func WithGpuValue added in v0.2.0

func WithGpuValue(b bool) ProxyOption

func WithPattern added in v0.1.2

func WithPattern(p string) ProxyOption

func WithPatterns added in v0.1.2

func WithPatterns(p []string) ProxyOption

func WithPinUser added in v0.2.3

func WithPinUser(pub bool, pu string) ProxyOption

func WithProxySocket added in v0.1.2

func WithProxySocket(s string) ProxyOption

type ProxyOptions added in v0.1.2

type ProxyOptions struct {
	DockerSocket, ProxySocket, PinUser, CudaLibPath string
	Debug, Gpu, PinUserEnabled                      bool
	Patterns, BindMounts, DevMappings               []string
}

type UnixSocket

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

UnixSocket just provides the path, so that I can test it

func NewUnixSocket

func NewUnixSocket(path string) UnixSocket

NewUnixSocket return a socket using the path

type UpStream

type UpStream struct {
	Name string
	// contains filtered or unexported fields
}

UpStream creates upstream handler struct

func NewUpstream

func NewUpstream(socket string, regs []string, binds []string, devs []string, gpu bool, pinUser string, pinUserB bool, cudaLibPath string) *UpStream

NewUpstream returns a new socket (magic)

func NewUpstreamPO added in v0.2.3

func NewUpstreamPO(po ProxyOptions) *UpStream

func (*UpStream) ServeHTTP

func (u *UpStream) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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