options

package
v0.0.0-...-6ca4c02 Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Options represents the configuration options for mungegithub.

Options are loaded from a yaml string->string configmap and are updated whenever Load is called. Options must be registered at least once before they can be retrieved, but registration and loading may happen in any order (this makes Options compatible with a plugin architecture). Option keys must be unique across all options of all types. Options may be registered multiple times safely so long as the option is always bound to the same pointer. (registration is idempotent) The defaultVal is used if the options does not have a value specified. The description explains the option as an entry in the text returned by Descriptions().

func New

func New() *Options

func (*Options) CurrentValues

func (o *Options) CurrentValues() string

func (*Options) Descriptions

func (o *Options) Descriptions() string

func (*Options) FlagsSpecified

func (o *Options) FlagsSpecified() sets.String

FlagsSpecified returns the names of the flags that were specified that correspond to options. This function must have been proceeded by a call to ToFlags and the flags must have been parsed since then.

func (*Options) GetBool

func (o *Options) GetBool(key string) *bool

GetBool gets the `bool` option under the specified key.

func (*Options) GetDuration

func (o *Options) GetDuration(key string) *time.Duration

GetDuration gets the `time.Duration` option under the specified key.

func (*Options) GetInt

func (o *Options) GetInt(key string) *int

GetInt gets then `int` option under the specified key.

func (*Options) GetString

func (o *Options) GetString(key string) *string

GetString gets the `string` option under the specified key.

func (*Options) GetStringSlice

func (o *Options) GetStringSlice(key string) *[]string

GetStringSlice gets the `[]string` option under the specified key.

func (*Options) GetUint64

func (o *Options) GetUint64(key string) *uint64

GetUint64 gets the `uint64` option under the specified key.

func (*Options) Load

func (o *Options) Load(file string) (sets.String, error)

Load updates options based on the contents of a config file and returns the set of changed options.

func (*Options) PopulateFromFlags

func (o *Options) PopulateFromFlags()

PopulateFromFlags loads values into options from command line flags. This function must be proceeded by a call to ToFlags and the flags must have been parsed since then.

func (*Options) PopulateFromString

func (o *Options) PopulateFromString(yaml string) sets.String

PopulateFromString loads values from the provided yaml string and returns the set of changed options. This function should only be used in tests where the config is not loaded from a file.

func (*Options) RegisterBool

func (o *Options) RegisterBool(ptr *bool, key string, defaultVal bool, description string)

RegisterBool registers a `bool` option under the specified key.

func (*Options) RegisterDuration

func (o *Options) RegisterDuration(ptr *time.Duration, key string, defaultVal time.Duration, description string)

RegisterDuration registers a `time.Duration` option under the specified key.

func (*Options) RegisterInt

func (o *Options) RegisterInt(ptr *int, key string, defaultVal int, description string)

RegisterInt registers an `int` option under the specified key.

func (*Options) RegisterString

func (o *Options) RegisterString(ptr *string, key string, defaultVal string, description string)

RegisterString registers a `string` option under the specified key.

func (*Options) RegisterStringSlice

func (o *Options) RegisterStringSlice(ptr *[]string, key string, defaultVal []string, description string)

RegisterStringSlice registers a `[]string` option under the specified key.

func (*Options) RegisterUint64

func (o *Options) RegisterUint64(ptr *uint64, key string, defaultVal uint64, description string)

RegisterUint64 registers a `uint64` option under the specified key.

func (*Options) RegisterUpdateCallback

func (o *Options) RegisterUpdateCallback(callback UpdateCallback)

func (*Options) ToFlags

func (o *Options) ToFlags()

ToFlags registers all options as string flags with the flag.CommandLine flagset. All options should be registered before ToFlags is called.

type UpdateCallback

type UpdateCallback func(changed sets.String) error

type UpdateCallbackError

type UpdateCallbackError struct {
	// contains filtered or unexported fields
}

func (*UpdateCallbackError) Error

func (e *UpdateCallbackError) Error() string

Jump to

Keyboard shortcuts

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