config

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: Apache-2.0 Imports: 11 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 = "NEW_RELIC_CLI"
)
View Source
const (
	// DefaultLogLevel is the default log level
	DefaultLogLevel = "INFO"

	// DefaultLogFile is the default log file
	DefaultLogFile = "newrelic-cli.log"
)

Variables

View Source
var Command = &cobra.Command{
	Use:   "config",
	Short: "Manage the configuration of the New Relic CLI",
}

Command is the base command for managing profiles

View Source
var (
	// DefaultConfigDirectory is the default location for the CLI config files
	DefaultConfigDirectory string
)
View Source
var TernaryValues = struct {
	// Allow the option
	Allow Ternary

	// Disallow the option
	Disallow Ternary

	// Unknown is the unknown state
	Unknown Ternary
}{
	Allow:    "ALLOW",
	Disallow: "DISALLOW",
	Unknown:  "NOT_ASKED",
}

TernaryValues provides the set of Ternary values

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      Ternary `mapstructure:"sendUsageData"`      // SendUsageData enables sending usage statistics to New Relic
	PreReleaseFeatures Ternary `mapstructure:"preReleaseFeatures"` // PreReleaseFeatures enables display on features within the CLI that are announced but not generally available to customers
	// 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 interface{}) error

Set is used to update a config value.

type LogrusFileHook added in v0.8.11

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

func NewLogrusFileHook added in v0.8.11

func NewLogrusFileHook(file string, flag int, chmod os.FileMode) (*LogrusFileHook, error)

func (*LogrusFileHook) Fire added in v0.8.11

func (hook *LogrusFileHook) Fire(entry *log.Entry) error

func (*LogrusFileHook) Levels added in v0.8.11

func (hook *LogrusFileHook) Levels() []log.Level

type Ternary added in v0.8.11

type Ternary string

Ternary is like a bool, but includes the unknown state

func (Ternary) Bool added in v0.8.11

func (t Ternary) Bool() bool

Bool returns true if the ternary is set and contains the true value

func (Ternary) String added in v0.8.11

func (t Ternary) String() string

String returns the string value of the ternary

func (Ternary) Valid added in v0.8.11

func (t Ternary) Valid() error

Valid returns true for a valid value, false otherwise

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