github.com/chenbh/concourse/v6@v6.4.2/worker/runtime/libcontainerd/container.go (about)

     1  package libcontainerd
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/containerd/containerd"
     8  	"github.com/containerd/containerd/cio"
     9  	"github.com/containerd/containerd/containers"
    10  	"github.com/containerd/containerd/oci"
    11  	prototypes "github.com/gogo/protobuf/types"
    12  )
    13  
    14  var _ containerd.Container = (*container)(nil)
    15  
    16  type container struct {
    17  	requestTimeout time.Duration
    18  	container      containerd.Container
    19  }
    20  
    21  func (c *container) ID() string {
    22  	return c.container.ID()
    23  }
    24  
    25  func (c *container) Info(ctx context.Context, opts ...containerd.InfoOpts) (containers.Container, error) {
    26  	return c.container.Info(ctx, opts...)
    27  }
    28  
    29  func (c *container) Delete(ctx context.Context, opts ...containerd.DeleteOpts) error {
    30  	return c.container.Delete(ctx, opts...)
    31  }
    32  
    33  func (c *container) NewTask(ctx context.Context, creator cio.Creator, opts ...containerd.NewTaskOpts) (containerd.Task, error) {
    34  	ctx, cancel := context.WithTimeout(ctx, c.requestTimeout)
    35  	defer cancel()
    36  
    37  	return c.container.NewTask(ctx, creator, opts...)
    38  }
    39  
    40  func (c *container) Spec(ctx context.Context) (*oci.Spec, error) {
    41  	ctx, cancel := context.WithTimeout(ctx, c.requestTimeout)
    42  	defer cancel()
    43  
    44  	return c.container.Spec(ctx)
    45  }
    46  
    47  func (c *container) Task(ctx context.Context, opt cio.Attach) (containerd.Task, error) {
    48  	ctx, cancel := context.WithTimeout(ctx, c.requestTimeout)
    49  	defer cancel()
    50  
    51  	return c.container.Task(ctx, opt)
    52  }
    53  
    54  func (c *container) Image(ctx context.Context) (containerd.Image, error) {
    55  	return c.container.Image(ctx)
    56  }
    57  
    58  func (c *container) Labels(ctx context.Context) (map[string]string, error) {
    59  	return c.container.Labels(ctx)
    60  }
    61  
    62  func (c *container) SetLabels(ctx context.Context, labels map[string]string) (map[string]string, error) {
    63  	return c.container.SetLabels(ctx, labels)
    64  
    65  }
    66  
    67  func (c *container) Extensions(ctx context.Context) (map[string]prototypes.Any, error) {
    68  	return c.container.Extensions(ctx)
    69  
    70  }
    71  
    72  func (c *container) Update(ctx context.Context, opts ...containerd.UpdateContainerOpts) error {
    73  	return c.container.Update(ctx, opts...)
    74  
    75  }
    76  
    77  func (c *container) Checkpoint(ctx context.Context, id string, opts ...containerd.CheckpointOpts) (containerd.Image, error) {
    78  	return c.container.Checkpoint(ctx, id, opts...)
    79  }