github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/libcontainerd/container.go (about)

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