github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/config/config_common_unix.go (about)

     1  // +build linux freebsd
     2  
     3  package config // import "github.com/demonoid81/moby/daemon/config"
     4  
     5  import (
     6  	"net"
     7  
     8  	"github.com/demonoid81/moby/api/types"
     9  )
    10  
    11  // CommonUnixConfig defines configuration of a docker daemon that is
    12  // common across Unix platforms.
    13  type CommonUnixConfig struct {
    14  	Runtimes          map[string]types.Runtime `json:"runtimes,omitempty"`
    15  	DefaultRuntime    string                   `json:"default-runtime,omitempty"`
    16  	DefaultInitBinary string                   `json:"default-init,omitempty"`
    17  }
    18  
    19  type commonUnixBridgeConfig struct {
    20  	DefaultIP                   net.IP `json:"ip,omitempty"`
    21  	IP                          string `json:"bip,omitempty"`
    22  	DefaultGatewayIPv4          net.IP `json:"default-gateway,omitempty"`
    23  	DefaultGatewayIPv6          net.IP `json:"default-gateway-v6,omitempty"`
    24  	InterContainerCommunication bool   `json:"icc,omitempty"`
    25  }
    26  
    27  // GetRuntime returns the runtime path and arguments for a given
    28  // runtime name
    29  func (conf *Config) GetRuntime(name string) *types.Runtime {
    30  	conf.Lock()
    31  	defer conf.Unlock()
    32  	if rt, ok := conf.Runtimes[name]; ok {
    33  		return &rt
    34  	}
    35  	return nil
    36  }
    37  
    38  // GetDefaultRuntimeName returns the current default runtime
    39  func (conf *Config) GetDefaultRuntimeName() string {
    40  	conf.Lock()
    41  	rt := conf.DefaultRuntime
    42  	conf.Unlock()
    43  
    44  	return rt
    45  }
    46  
    47  // GetAllRuntimes returns a copy of the runtimes map
    48  func (conf *Config) GetAllRuntimes() map[string]types.Runtime {
    49  	conf.Lock()
    50  	rts := conf.Runtimes
    51  	conf.Unlock()
    52  	return rts
    53  }
    54  
    55  // GetExecRoot returns the user configured Exec-root
    56  func (conf *Config) GetExecRoot() string {
    57  	return conf.ExecRoot
    58  }
    59  
    60  // GetInitPath returns the configured docker-init path
    61  func (conf *Config) GetInitPath() string {
    62  	conf.Lock()
    63  	defer conf.Unlock()
    64  	if conf.InitPath != "" {
    65  		return conf.InitPath
    66  	}
    67  	if conf.DefaultInitBinary != "" {
    68  		return conf.DefaultInitBinary
    69  	}
    70  	return DefaultInitBinary
    71  }
    72  
    73  // GetResolvConf returns the appropriate resolv.conf
    74  // Check setupResolvConf on how this is selected
    75  func (conf *Config) GetResolvConf() string {
    76  	return conf.ResolvConf
    77  }