github.com/kardianos/nomad@v0.1.3-0.20151022182107-b13df73ee850/client/config/config.go (about) 1 package config 2 3 import ( 4 "io" 5 6 "github.com/hashicorp/nomad/nomad/structs" 7 ) 8 9 // RPCHandler can be provided to the Client if there is a local server 10 // to avoid going over the network. If not provided, the Client will 11 // maintain a connection pool to the servers 12 type RPCHandler interface { 13 RPC(method string, args interface{}, reply interface{}) error 14 } 15 16 // Config is used to parameterize and configure the behavior of the client 17 type Config struct { 18 // DevMode controls if we are in a development mode which 19 // avoids persistent storage. 20 DevMode bool 21 22 // StateDir is where we store our state 23 StateDir string 24 25 // AllocDir is where we store data for allocations 26 AllocDir string 27 28 // LogOutput is the destination for logs 29 LogOutput io.Writer 30 31 // Region is the clients region 32 Region string 33 34 // Network interface to be used in network fingerprinting 35 NetworkInterface string 36 37 // Network speed is the default speed of network interfaces if they can not 38 // be determined dynamically. 39 NetworkSpeed int 40 41 // Servers is a list of known server addresses. These are as "host:port" 42 Servers []string 43 44 // RPCHandler can be provided to avoid network traffic if the 45 // server is running locally. 46 RPCHandler RPCHandler 47 48 // Node provides the base node 49 Node *structs.Node 50 51 // Options provides arbitrary key-value configuration for nomad internals, 52 // like fingerprinters and drivers. The format is: 53 // 54 // namespace.option = value 55 Options map[string]string 56 } 57 58 // Read returns the specified configuration value or "". 59 func (c *Config) Read(id string) string { 60 val, ok := c.Options[id] 61 if !ok { 62 return "" 63 } 64 return val 65 } 66 67 // ReadDefault returns the specified configuration value, or the specified 68 // default value if none is set. 69 func (c *Config) ReadDefault(id string, defaultValue string) string { 70 val := c.Read(id) 71 if val != "" { 72 return val 73 } 74 return defaultValue 75 }