Update client to pass go lint
There is one breaking change with the function naming of UidGid to UIDGID Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
8e447197bc
commit
51b9240b80
10
client.go
10
client.go
@ -406,42 +406,52 @@ func (c *Client) Close() error {
|
|||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NamespaceService returns the underlying NamespacesClient
|
||||||
func (c *Client) NamespaceService() namespacesapi.NamespacesClient {
|
func (c *Client) NamespaceService() namespacesapi.NamespacesClient {
|
||||||
return namespacesapi.NewNamespacesClient(c.conn)
|
return namespacesapi.NewNamespacesClient(c.conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerService returns the underlying container Store
|
||||||
func (c *Client) ContainerService() containers.Store {
|
func (c *Client) ContainerService() containers.Store {
|
||||||
return NewRemoteContainerStore(containersapi.NewContainersClient(c.conn))
|
return NewRemoteContainerStore(containersapi.NewContainersClient(c.conn))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContentStore returns the underlying content Store
|
||||||
func (c *Client) ContentStore() content.Store {
|
func (c *Client) ContentStore() content.Store {
|
||||||
return contentservice.NewStoreFromClient(contentapi.NewContentClient(c.conn))
|
return contentservice.NewStoreFromClient(contentapi.NewContentClient(c.conn))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SnapshotService returns the underlying snapshotter for the provided snapshotter name
|
||||||
func (c *Client) SnapshotService(snapshotterName string) snapshot.Snapshotter {
|
func (c *Client) SnapshotService(snapshotterName string) snapshot.Snapshotter {
|
||||||
return snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(c.conn), snapshotterName)
|
return snapshotservice.NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(c.conn), snapshotterName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TaskService returns the underlying TasksClient
|
||||||
func (c *Client) TaskService() tasks.TasksClient {
|
func (c *Client) TaskService() tasks.TasksClient {
|
||||||
return tasks.NewTasksClient(c.conn)
|
return tasks.NewTasksClient(c.conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageService returns the underlying image Store
|
||||||
func (c *Client) ImageService() images.Store {
|
func (c *Client) ImageService() images.Store {
|
||||||
return imagesservice.NewStoreFromClient(imagesapi.NewImagesClient(c.conn))
|
return imagesservice.NewStoreFromClient(imagesapi.NewImagesClient(c.conn))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiffService returns the underlying DiffService
|
||||||
func (c *Client) DiffService() diff.DiffService {
|
func (c *Client) DiffService() diff.DiffService {
|
||||||
return diffservice.NewDiffServiceFromClient(diffapi.NewDiffClient(c.conn))
|
return diffservice.NewDiffServiceFromClient(diffapi.NewDiffClient(c.conn))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HealthService returns the underlying GRPC HealthClient
|
||||||
func (c *Client) HealthService() grpc_health_v1.HealthClient {
|
func (c *Client) HealthService() grpc_health_v1.HealthClient {
|
||||||
return grpc_health_v1.NewHealthClient(c.conn)
|
return grpc_health_v1.NewHealthClient(c.conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventService returns the underlying EventsClient
|
||||||
func (c *Client) EventService() eventsapi.EventsClient {
|
func (c *Client) EventService() eventsapi.EventsClient {
|
||||||
return eventsapi.NewEventsClient(c.conn)
|
return eventsapi.NewEventsClient(c.conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VersionService returns the underlying VersionClient
|
||||||
func (c *Client) VersionService() versionservice.VersionClient {
|
func (c *Client) VersionService() versionservice.VersionClient {
|
||||||
return versionservice.NewVersionClient(c.conn)
|
return versionservice.NewVersionClient(c.conn)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ type remoteContainers struct {
|
|||||||
|
|
||||||
var _ containers.Store = &remoteContainers{}
|
var _ containers.Store = &remoteContainers{}
|
||||||
|
|
||||||
|
// NewRemoteContainerStore returns the container Store connected with the provided client
|
||||||
func NewRemoteContainerStore(client containersapi.ContainersClient) containers.Store {
|
func NewRemoteContainerStore(client containersapi.ContainersClient) containers.Store {
|
||||||
return &remoteContainers{
|
return &remoteContainers{
|
||||||
client: client,
|
client: client,
|
||||||
|
@ -13,6 +13,7 @@ type dialResult struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dialer returns a GRPC net.Conn connected to the provided address
|
||||||
func Dialer(address string, timeout time.Duration) (net.Conn, error) {
|
func Dialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||||
var (
|
var (
|
||||||
stopC = make(chan struct{})
|
stopC = make(chan struct{})
|
||||||
|
@ -27,6 +27,8 @@ func dialer(address string, timeout time.Duration) (net.Conn, error) {
|
|||||||
return net.DialTimeout("unix", address, timeout)
|
return net.DialTimeout("unix", address, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DialAddress returns the address with unix:// prepended to the
|
||||||
|
// provided address
|
||||||
func DialAddress(address string) string {
|
func DialAddress(address string) string {
|
||||||
return fmt.Sprintf("unix://%s", address)
|
return fmt.Sprintf("unix://%s", address)
|
||||||
}
|
}
|
||||||
|
12
io_unix.go
12
io_unix.go
@ -119,6 +119,7 @@ func NewDirectIO(ctx context.Context, terminal bool) (*DirectIO, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirectIO allows task IO to be handled externally by the caller
|
||||||
type DirectIO struct {
|
type DirectIO struct {
|
||||||
Stdin io.WriteCloser
|
Stdin io.WriteCloser
|
||||||
Stdout io.ReadCloser
|
Stdout io.ReadCloser
|
||||||
@ -128,14 +129,17 @@ type DirectIO struct {
|
|||||||
terminal bool
|
terminal bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IOCreate returns IO avaliable for use with task creation
|
||||||
func (f *DirectIO) IOCreate(id string) (IO, error) {
|
func (f *DirectIO) IOCreate(id string) (IO, error) {
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IOAttach returns IO avaliable for use with task attachment
|
||||||
func (f *DirectIO) IOAttach(set *FIFOSet) (IO, error) {
|
func (f *DirectIO) IOAttach(set *FIFOSet) (IO, error) {
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config returns the IOConfig
|
||||||
func (f *DirectIO) Config() IOConfig {
|
func (f *DirectIO) Config() IOConfig {
|
||||||
return IOConfig{
|
return IOConfig{
|
||||||
Terminal: f.terminal,
|
Terminal: f.terminal,
|
||||||
@ -145,14 +149,21 @@ func (f *DirectIO) Config() IOConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel stops any IO copy operations
|
||||||
|
//
|
||||||
|
// Not applicable for DirectIO
|
||||||
func (f *DirectIO) Cancel() {
|
func (f *DirectIO) Cancel() {
|
||||||
// nothing to cancel as all operations are handled externally
|
// nothing to cancel as all operations are handled externally
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait on any IO copy operations
|
||||||
|
//
|
||||||
|
// Not applicable for DirectIO
|
||||||
func (f *DirectIO) Wait() {
|
func (f *DirectIO) Wait() {
|
||||||
// nothing to wait on as all operations are handled externally
|
// nothing to wait on as all operations are handled externally
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes all open fds
|
||||||
func (f *DirectIO) Close() error {
|
func (f *DirectIO) Close() error {
|
||||||
err := f.Stdin.Close()
|
err := f.Stdin.Close()
|
||||||
if err2 := f.Stdout.Close(); err == nil {
|
if err2 := f.Stdout.Close(); err == nil {
|
||||||
@ -164,6 +175,7 @@ func (f *DirectIO) Close() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete removes the underlying directory containing fifos
|
||||||
func (f *DirectIO) Delete() error {
|
func (f *DirectIO) Delete() error {
|
||||||
if f.set.Dir == "" {
|
if f.set.Dir == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -302,8 +302,8 @@ func WithNamespacedCgroup() SpecOpts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithUidGid allows the UID and GID for the Process to be set
|
// WithUIDGID allows the UID and GID for the Process to be set
|
||||||
func WithUidGid(uid, gid uint32) SpecOpts {
|
func WithUIDGID(uid, gid uint32) SpecOpts {
|
||||||
return func(_ context.Context, _ *Client, _ *containers.Container, s *specs.Spec) error {
|
return func(_ context.Context, _ *Client, _ *containers.Container, s *specs.Spec) error {
|
||||||
s.Process.User.UID = uid
|
s.Process.User.UID = uid
|
||||||
s.Process.User.GID = gid
|
s.Process.User.GID = gid
|
||||||
|
1
task.go
1
task.go
@ -41,6 +41,7 @@ type Status struct {
|
|||||||
ExitTime time.Time
|
ExitTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProcessStatus returns a human readable status for the Process representing its current status
|
||||||
type ProcessStatus string
|
type ProcessStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -52,12 +52,14 @@ func WithProcessKill(ctx context.Context, p Process) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KillInfo contains information on how to process a Kill action
|
||||||
type KillInfo struct {
|
type KillInfo struct {
|
||||||
// All kills all processes inside the task
|
// All kills all processes inside the task
|
||||||
// only valid on tasks, ignored on processes
|
// only valid on tasks, ignored on processes
|
||||||
All bool
|
All bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KillOpts allows options to be set for the killing of a process
|
||||||
type KillOpts func(context.Context, Process, *KillInfo) error
|
type KillOpts func(context.Context, Process, *KillInfo) error
|
||||||
|
|
||||||
// WithKillAll kills all processes for a task
|
// WithKillAll kills all processes for a task
|
||||||
|
Loading…
Reference in New Issue
Block a user