github.com/go/docker@v1.12.0-rc2/libcontainerd/container.go (about)

     1  package libcontainerd
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"github.com/docker/docker/restartmanager"
     8  )
     9  
    10  const (
    11  	// InitFriendlyName is the name given in the lookup map of processes
    12  	// for the first process started in a container.
    13  	InitFriendlyName = "init"
    14  	configFilename   = "config.json"
    15  )
    16  
    17  type containerCommon struct {
    18  	process
    19  	restartManager restartmanager.RestartManager
    20  	restarting     bool
    21  	processes      map[string]*process
    22  	startedAt      time.Time
    23  }
    24  
    25  // WithRestartManager sets the restartmanager to be used with the container.
    26  func WithRestartManager(rm restartmanager.RestartManager) CreateOption {
    27  	return restartManager{rm}
    28  }
    29  
    30  type restartManager struct {
    31  	rm restartmanager.RestartManager
    32  }
    33  
    34  func (rm restartManager) Apply(p interface{}) error {
    35  	if pr, ok := p.(*container); ok {
    36  		pr.restartManager = rm.rm
    37  		return nil
    38  	}
    39  	return fmt.Errorf("WithRestartManager option not supported for this client")
    40  }