github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/libcontainerd/remote_daemon_options_linux.go (about)

     1  package libcontainerd
     2  
     3  import "fmt"
     4  
     5  // WithOOMScore defines the oom_score_adj to set for the containerd process.
     6  func WithOOMScore(score int) RemoteOption {
     7  	return oomScore(score)
     8  }
     9  
    10  type oomScore int
    11  
    12  func (o oomScore) Apply(r Remote) error {
    13  	if remote, ok := r.(*remote); ok {
    14  		remote.OOMScore = int(o)
    15  		return nil
    16  	}
    17  	return fmt.Errorf("WithOOMScore option not supported for this remote")
    18  }
    19  
    20  // WithSubreaper sets whether containerd should register itself as a
    21  // subreaper
    22  func WithSubreaper(reap bool) RemoteOption {
    23  	return subreaper(reap)
    24  }
    25  
    26  type subreaper bool
    27  
    28  func (s subreaper) Apply(r Remote) error {
    29  	if remote, ok := r.(*remote); ok {
    30  		remote.NoSubreaper = !bool(s)
    31  		return nil
    32  	}
    33  	return fmt.Errorf("WithSubreaper option not supported for this remote")
    34  }