container.go 916 B

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