github.com/devdivbcp/moby@v17.12.0-ce-rc1.0.20200726071732-2d4bfdc789ad+incompatible/daemon/reload_unix.go (about)

     1  // +build linux freebsd
     2  
     3  package daemon // import "github.com/docker/docker/daemon"
     4  
     5  import (
     6  	"bytes"
     7  	"fmt"
     8  
     9  	"github.com/docker/docker/api/types"
    10  	"github.com/docker/docker/daemon/config"
    11  )
    12  
    13  // reloadPlatform updates configuration with platform specific options
    14  // and updates the passed attributes
    15  func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string]string) error {
    16  	if err := conf.ValidatePlatformConfig(); err != nil {
    17  		return err
    18  	}
    19  
    20  	if conf.IsValueSet("runtimes") {
    21  		// Always set the default one
    22  		conf.Runtimes[config.StockRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary}
    23  		if err := daemon.initRuntimes(conf.Runtimes); err != nil {
    24  			return err
    25  		}
    26  		daemon.configStore.Runtimes = conf.Runtimes
    27  	}
    28  
    29  	if conf.DefaultRuntime != "" {
    30  		daemon.configStore.DefaultRuntime = conf.DefaultRuntime
    31  	}
    32  
    33  	if conf.IsValueSet("default-shm-size") {
    34  		daemon.configStore.ShmSize = conf.ShmSize
    35  	}
    36  
    37  	if conf.IpcMode != "" {
    38  		daemon.configStore.IpcMode = conf.IpcMode
    39  	}
    40  
    41  	// Update attributes
    42  	var runtimeList bytes.Buffer
    43  	for name, rt := range daemon.configStore.Runtimes {
    44  		if runtimeList.Len() > 0 {
    45  			runtimeList.WriteRune(' ')
    46  		}
    47  		runtimeList.WriteString(fmt.Sprintf("%s:%s", name, rt))
    48  	}
    49  
    50  	attributes["runtimes"] = runtimeList.String()
    51  	attributes["default-runtime"] = daemon.configStore.DefaultRuntime
    52  	attributes["default-shm-size"] = fmt.Sprintf("%d", daemon.configStore.ShmSize)
    53  	attributes["default-ipc-mode"] = daemon.configStore.IpcMode
    54  
    55  	return nil
    56  }