Add shim start opts
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
f968359ecb
commit
993b863993
@ -42,7 +42,7 @@ type service struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StartShim is a binary call that executes a new shim returning the address
|
// StartShim is a binary call that executes a new shim returning the address
|
||||||
func (s *service) StartShim(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string) (string, error) {
|
func (s *service) StartShim(ctx context.Context, opts shim.StartOpts) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,12 +126,12 @@ func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, co
|
|||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) StartShim(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string) (_ string, retErr error) {
|
func (s *service) StartShim(ctx context.Context, opts shim.StartOpts) (_ string, retErr error) {
|
||||||
cmd, err := newCommand(ctx, id, containerdBinary, containerdAddress, containerdTTRPCAddress)
|
cmd, err := newCommand(ctx, opts.ID, opts.ContainerdBinary, opts.Address, opts.TTRPCAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
address, err := shim.SocketAddress(ctx, containerdAddress, id)
|
address, err := shim.SocketAddress(ctx, opts.Address, opts.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -171,12 +171,12 @@ func readSpec() (*spec, error) {
|
|||||||
return &s, nil
|
return &s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) StartShim(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string) (_ string, retErr error) {
|
func (s *service) StartShim(ctx context.Context, opts shim.StartOpts) (_ string, retErr error) {
|
||||||
cmd, err := newCommand(ctx, id, containerdBinary, containerdAddress, containerdTTRPCAddress)
|
cmd, err := newCommand(ctx, opts.ID, opts.ContainerdBinary, opts.Address, opts.TTRPCAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
grouping := id
|
grouping := opts.ID
|
||||||
spec, err := readSpec()
|
spec, err := readSpec()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -187,7 +187,7 @@ func (s *service) StartShim(ctx context.Context, id, containerdBinary, container
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
address, err := shim.SocketAddress(ctx, containerdAddress, grouping)
|
address, err := shim.SocketAddress(ctx, opts.Address, grouping)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,14 @@ type Publisher interface {
|
|||||||
io.Closer
|
io.Closer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StartOpts describes shim start configuration received from containerd
|
||||||
|
type StartOpts struct {
|
||||||
|
ID string
|
||||||
|
ContainerdBinary string
|
||||||
|
Address string
|
||||||
|
TTRPCAddress string
|
||||||
|
}
|
||||||
|
|
||||||
// Init func for the creation of a shim server
|
// Init func for the creation of a shim server
|
||||||
type Init func(context.Context, string, Publisher, func()) (Shim, error)
|
type Init func(context.Context, string, Publisher, func()) (Shim, error)
|
||||||
|
|
||||||
@ -58,7 +66,7 @@ type Init func(context.Context, string, Publisher, func()) (Shim, error)
|
|||||||
type Shim interface {
|
type Shim interface {
|
||||||
shimapi.TaskService
|
shimapi.TaskService
|
||||||
Cleanup(ctx context.Context) (*shimapi.DeleteResponse, error)
|
Cleanup(ctx context.Context) (*shimapi.DeleteResponse, error)
|
||||||
StartShim(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string) (string, error)
|
StartShim(ctx context.Context, opts StartOpts) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OptsKey is the context key for the Opts value.
|
// OptsKey is the context key for the Opts value.
|
||||||
@ -219,7 +227,13 @@ func run(id string, initFunc Init, config Config) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case "start":
|
case "start":
|
||||||
address, err := service.StartShim(ctx, idFlag, containerdBinaryFlag, addressFlag, ttrpcAddress)
|
opts := StartOpts{
|
||||||
|
ID: idFlag,
|
||||||
|
ContainerdBinary: containerdBinaryFlag,
|
||||||
|
Address: addressFlag,
|
||||||
|
TTRPCAddress: ttrpcAddress,
|
||||||
|
}
|
||||||
|
address, err := service.StartShim(ctx, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user