config

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config handles config files, -config, and env vars at startup.

Index

Constants

View Source
const (
	DEFAULT_CONFIG_FILES = "/etc/etre/es.yaml,~/.es.yaml"
	DEFAULT_IFS          = ","
	DEFAULT_TIMEOUT      = 5000 // 5s
)

Variables

View Source
var (
	ErrUnknownRequest = errors.New("request does not exist")
)

Functions

func DefaultTrace

func DefaultTrace() string

func Help

func Help()

func ParseArgs

func ParseArgs(args []string) (string, []string, string)

Types

type CommandLine

type CommandLine struct {
	Options
	Args []string `arg:"positional"`
}

CommandLine represents options (--addr, etc.) and args: entity type, return labels, and query predicates. The caller is expected to copy and use the embedded structs separately, like:

var o config.Options = cmdLine.Options
for i, arg := range cmdline.Args {

func ParseCommandLine

func ParseCommandLine(def Options) CommandLine

ParseCommandLine parses the command line and env vars. Command line options override env vars. Default options are used unless overridden by env vars or command line options. Defaults are usually parsed from config files.

type Options

type Options struct {
	Addr        string `arg:"env:ES_ADDR" yaml:"addr"`
	Config      string `arg:"env:ES_CONFIG"`
	Debug       bool   `arg:"env:ES_DEBUG" yaml:"debug"`
	Delete      bool
	DeleteLabel bool   `arg:"--delete-label"`
	Env         string `arg:"env:ES_ENV" yaml:"env"`
	Help        bool
	JSON        bool   `arg:"env:ES_JSON" yaml:"json"`
	IFS         string `arg:"env" yaml:"ifs"`
	Labels      bool   `arg:"env:ES_LABELS" yaml:"labels"`
	Ping        bool
	Old         bool   `arg:"env:ES_OLD" yaml:"old"`
	SetOp       string `arg:"--set-op,env:ES_SET_OP"`
	SetId       string `arg:"--set-id,env:ES_SET_ID"`
	SetSize     int    `arg:"--set-size,env:ES_SET_SIZE"`
	Strict      bool   `arg:"env:ES_STRICT" yaml:"strict"`
	Timeout     uint   `arg:"env:ES_TIMEOUT" yaml:"timeout"`
	Trace       string `arg:"env:ES_TRACE" yaml:"trace"`
	Update      bool
	Version     bool `arg:"-v"`
}

Options represents typical command line options: --addr, --config, etc.

func ParseConfigFiles

func ParseConfigFiles(files string, debug bool) Options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL