goiardi: github.com/theckman/goiardi/config Index | Files

package config

import "github.com/theckman/goiardi/config"

Package config parses command line flags and config files, and defines options used elsewhere in goiardi.


Package Files



const ChefVersion = "11.1.7"

The chef version we're at least aiming for, even if it's not complete yet.

const DefaultTimeSlew = "15m"

The default time difference allowed between the server's clock and the time in the X-OPS-TIMESTAMP header.

const Version = "0.10.1"

The goiardi version.


var Config = initConfig()

Config struct with the options specified on the command line or in the config file.

var Key = &SigningKeys{}

Key is the initialized shovey public and private keys.

var LogLevelNames = map[string]int{"debug": 4, "info": 3, "warning": 2, "error": 1, "critical": 0}

LogLevelNames give convenient, easier to remember than number name for the different levels of logging.

func ListenAddr Uses

func ListenAddr() string

ListenAddr builds the address and port goiardi is configured to listen on.

func ParseConfigOptions Uses

func ParseConfigOptions() error

ParseConfigOptions reads and applies arguments from the command line and the configuration file, merging them together as needed, with command line options taking precedence over options in the config file.

func ServerBaseURL Uses

func ServerBaseURL() string

ServerBaseURL returns the base scheme+hostname portion of a goiardi URL.

func ServerHostname Uses

func ServerHostname() string

ServerHostname returns the hostname and port goiardi is configured to use.

func UsingDB Uses

func UsingDB() bool

UsingDB returns true if we're using any db engine, false if using the in-memory data store.

type Conf Uses

type Conf struct {
    Ipaddress         string
    Port              int
    Hostname          string
    ConfFile          string `toml:"conf-file"`
    IndexFile         string `toml:"index-file"`
    DataStoreFile     string `toml:"data-file"`
    DebugLevel        int    `toml:"debug-level"`
    LogLevel          string `toml:"log-level"`
    FreezeInterval    int    `toml:"freeze-interval"`
    FreezeData        bool   `toml:"freeze-data"`
    LogFile           string `toml:"log-file"`
    SysLog            bool   `toml:"syslog"`
    UseAuth           bool   `toml:"use-auth"`
    TimeSlew          string `toml:"time-slew"`
    TimeSlewDur       time.Duration
    ConfRoot          string       `toml:"conf-root"`
    UseSSL            bool         `toml:"use-ssl"`
    SSLCert           string       `toml:"ssl-cert"`
    SSLKey            string       `toml:"ssl-key"`
    HTTPSUrls         bool         `toml:"https-urls"`
    DisableWebUI      bool         `toml:"disable-webui"`
    UseMySQL          bool         `toml:"use-mysql"`
    MySQL             MySQLdb      `toml:"mysql"`
    UsePostgreSQL     bool         `toml:"use-postgresql"`
    PostgreSQL        PostgreSQLdb `toml:"postgresql"`
    LocalFstoreDir    string       `toml:"local-filestore-dir"`
    LogEvents         bool         `toml:"log-events"`
    LogEventKeep      int          `toml:"log-event-keep"`
    DoExport          bool
    DoImport          bool
    ImpExFile         string
    ObjMaxSize        int64  `toml:"obj-max-size"`
    JSONReqMaxSize    int64  `toml:"json-req-max-size"`
    UseUnsafeMemStore bool   `toml:"use-unsafe-mem-store"`
    DbPoolSize        int    `toml:"db-pool-size"`
    MaxConn           int    `toml:"max-connections"`
    UseSerf           bool   `toml:"use-serf"`
    SerfEventAnnounce bool   `toml:"serf-event-announce"`
    SerfAddr          string `toml:"serf-addr"`
    UseShovey         bool   `toml:"use-shovey"`
    SignPrivKey       string `toml:"sign-priv-key"`
    DotSearch         bool   `toml:"dot-search"`
    ConvertSearch     bool   `toml:"convert-search"`
    PgSearch          bool   `toml:"pg-search"`

Conf is the master struct for holding configuration options.

type MySQLdb Uses

type MySQLdb struct {
    Username    string
    Password    string
    Protocol    string
    Address     string
    Port        string
    Dbname      string
    ExtraParams map[string]string `toml:"extra_params"`

MySQLdb holds MySQL connection options.

type Options Uses

type Options struct {
    Version           bool   `short:"v" long:"version" description:"Print version info."`
    Verbose           []bool `short:"V" long:"verbose" description:"Show verbose debug information. Repeat for more verbosity."`
    ConfFile          string `short:"c" long:"config" description:"Specify a config file to use."`
    Ipaddress         string `short:"I" long:"ipaddress" description:"Listen on a specific IP address."`
    Hostname          string `short:"H" long:"hostname" description:"Hostname to use for this server. Defaults to hostname reported by the kernel."`
    Port              int    `short:"P" long:"port" description:"Port to listen on. If port is set to 443, SSL will be activated. (default: 4545)"`
    IndexFile         string `short:"i" long:"index-file" description:"File to save search index data to."`
    DataStoreFile     string `short:"D" long:"data-file" description:"File to save data store data to."`
    FreezeInterval    int    `short:"F" long:"freeze-interval" description:"Interval in seconds to freeze in-memory data structures to disk if there have been any changes (requires -i/--index-file and -D/--data-file options to be set). (Default 10 seconds.)"`
    LogFile           string `short:"L" long:"log-file" description:"Log to file X"`
    SysLog            bool   `short:"s" long:"syslog" description:"Log to syslog rather than a log file. Incompatible with -L/--log-file."`
    TimeSlew          string `long:"time-slew" description:"Time difference allowed between the server's clock and the time in the X-OPS-TIMESTAMP header. Formatted like 5m, 150s, etc. Defaults to 15m."`
    ConfRoot          string `long:"conf-root" description:"Root directory for configs and certificates. Default: the directory the config file is in, or the current directory if no config file is set."`
    UseAuth           bool   `short:"A" long:"use-auth" description:"Use authentication. Default: false."`
    UseSSL            bool   `long:"use-ssl" description:"Use SSL for connections. If --port is set to 433, this will automatically be turned on. If it is set to 80, it will automatically be turned off. Default: off. Requires --ssl-cert and --ssl-key."`
    SSLCert           string `long:"ssl-cert" description:"SSL certificate file. If a relative path, will be set relative to --conf-root."`
    SSLKey            string `long:"ssl-key" description:"SSL key file. If a relative path, will be set relative to --conf-root."`
    HTTPSUrls         bool   `long:"https-urls" description:"Use 'https://' in URLs to server resources if goiardi is not using SSL for its connections. Useful when goiardi is sitting behind a reverse proxy that uses SSL, but is communicating with the proxy over HTTP."`
    DisableWebUI      bool   `long:"disable-webui" description:"If enabled, disables connections and logins to goiardi over the webui interface."`
    UseMySQL          bool   `long:"use-mysql" description:"Use a MySQL database for data storage. Configure database options in the config file."`
    UsePostgreSQL     bool   `long:"use-postgresql" description:"Use a PostgreSQL database for data storage. Configure database options in the config file."`
    LocalFstoreDir    string `long:"local-filestore-dir" description:"Directory to save uploaded files in. Optional when running in in-memory mode, *mandatory* for SQL mode."`
    LogEvents         bool   `long:"log-events" description:"Log changes to chef objects."`
    LogEventKeep      int    `short:"K" long:"log-event-keep" description:"Number of events to keep in the event log. If set, the event log will be checked periodically and pruned to this number of entries."`
    Export            string `short:"x" long:"export" description:"Export all server data to the given file, exiting afterwards. Should be used with caution. Cannot be used at the same time as -m/--import."`
    Import            string `short:"m" long:"import" description:"Import data from the given file, exiting afterwards. Cannot be used at the same time as -x/--export."`
    ObjMaxSize        int64  `short:"Q" long:"obj-max-size" description:"Maximum object size in bytes for the file store. Default 10485760 bytes (10MB)."`
    JSONReqMaxSize    int64  `short:"j" long:"json-req-max-size" description:"Maximum size for a JSON request from the client. Per chef-pedant, default is 1000000."`
    UseUnsafeMemStore bool   `long:"use-unsafe-mem-store" description:"Use the faster, but less safe, old method of storing data in the in-memory data store with pointers, rather than encoding the data with gob and giving a new copy of the object to each requestor. If this is enabled goiardi will run faster in in-memory mode, but one goroutine could change an object while it's being used by another. Has no effect when using an SQL backend."`
    DbPoolSize        int    `long:"db-pool-size" description:"Number of idle db connections to maintain. Only useful when using one of the SQL backends. Default is 0 - no idle connections retained"`
    MaxConn           int    `long:"max-connections" description:"Maximum number of connections allowed for the database. Only useful when using one of the SQL backends. Default is 0 - unlimited."`
    UseSerf           bool   `long:"use-serf" description:"If set, have goidari use serf to send and receive events and queries from a serf cluster. Required for shovey."`
    SerfEventAnnounce bool   `long:"serf-event-announce" description:"Announce log events and joining the serf cluster over serf, as serf events. Requires --use-serf."`
    SerfAddr          string `long:"serf-addr" description:"IP address and port to use for RPC communication with a serf agent. Defaults to"`
    UseShovey         bool   `long:"use-shovey" description:"Enable using shovey for sending jobs to nodes. Requires --use-serf."`
    SignPrivKey       string `long:"sign-priv-key" description:"Path to RSA private key used to sign shovey requests."`
    DotSearch         bool   `long:"dot-search" description:"If set, searches will use . to separate elements instead of _."`
    ConvertSearch     bool   `long:"convert-search" description:"If set, convert _ syntax searches to . syntax. Only useful if --dot-search is set."`
    PgSearch          bool   `long:"pg-search" description:"Use the new Postgres based search engine instead of the default ersatz Solr. Requires --use-postgresql, automatically turns on --dot-search. --convert-search is recommended, but not required."`

Options holds options set from the command line, which are then merged with the options in Conf. Configurations from the command line are preferred to those set in the config file.

type PostgreSQLdb Uses

type PostgreSQLdb struct {
    Username string
    Password string
    Host     string
    Port     string
    Dbname   string
    SSLMode  string

PostgreSQLdb holds Postgres connection options.

type SigningKeys Uses

type SigningKeys struct {
    PrivKey *rsa.PrivateKey

SigningKeys are the public and private keys for signing shovey requests.

Package config imports 17 packages (graph) and is imported by 20 packages. Updated 2016-07-29. Refresh now. Tools for package owners.