config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultConfigName is the default name of the global configuration file
	DefaultConfigName = "config"

	// DefaultConfigType to read, though any file type supported by viper is allowed
	DefaultConfigType = "json"

	// DefaultEnvPrefix is used when reading environment variables
	DefaultEnvPrefix = "newrelic"

	// DefaultLogLevel is the default log level
	DefaultLogLevel = "INFO"

	// DefaultSendUsageData is the default value for sendUsageData
	DefaultSendUsageData = "NOT_ASKED"
)

Variables

View Source
var Command = &cobra.Command{
	Use:   "config",
	Short: "Subcommands to manage the configuration of this tool",
}

Command is the base command for managing profiles

View Source
var (
	// DefaultConfigDirectory is the default location for the CLI config files
	DefaultConfigDirectory string
)

Functions

func WithConfig

func WithConfig(f func(c *Config))

WithConfig loads and returns the CLI configuration.

func WithConfigFrom

func WithConfigFrom(configDir string, f func(c *Config))

WithConfigFrom loads and returns the CLI configuration from a specified location.

Types

type Config

type Config struct {
	LogLevel      string `mapstructure:"logLevel"`      // LogLevel for verbose output
	PluginDir     string `mapstructure:"pluginDir"`     // PluginDir is the directory where plugins will be installed
	SendUsageData string `mapstructure:"sendUsageData"` // SendUsageData enables sending usage statistics to New Relic
	// contains filtered or unexported fields
}

Config contains the main CLI configuration

func LoadConfig

func LoadConfig(configDir string) (*Config, error)

LoadConfig loads the configuration from disk, substituting defaults if the file does not exist.

func (*Config) Delete

func (c *Config) Delete(key string) error

Delete deletes a config value. This has the effect of reverting the value back to its default.

func (*Config) Get

func (c *Config) Get(key string)

Get retrieves a config value.

func (*Config) List

func (c *Config) List()

List outputs a list of all the configuration values

func (*Config) Set

func (c *Config) Set(key string, value string) error

Set sets a config value.

type TableRenderer

type TableRenderer struct{}

TableRenderer represents the presentation layer for human readable command output.

func NewTableRenderer

func NewTableRenderer() *TableRenderer

NewTableRenderer returns a new instance of TableRenderer.

func (*TableRenderer) Delete

func (tr *TableRenderer) Delete(key string)

Delete renders output for the delete command.

func (*TableRenderer) Get

func (tr *TableRenderer) Get(c *Config, key string)

Get renders output for the get command.

func (*TableRenderer) List

func (tr *TableRenderer) List(c *Config)

List renders output for the list command.

func (*TableRenderer) Set

func (tr *TableRenderer) Set(key string, value string)

Set renders output for the set command.

type Value

type Value struct {
	Name    string
	Value   interface{}
	Default interface{}
}

Value represents an instance of a configuration field.

func (*Value) IsDefault

func (c *Value) IsDefault() bool

IsDefault returns true if the field's value is the default value.

Jump to

Keyboard shortcuts

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