api

package
v0.44.6 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteConfigValue

func DeleteConfigValue(key config.FieldKey) error

DeleteConfigValue deletes a config value for the given key.

func ForEachConfigFieldDefinition

func ForEachConfigFieldDefinition(fn func(d config.FieldDefinition))

ForEachConfigFieldDefinition iterates the field definitions for the config fields.

func ForEachProfileFieldDefinition

func ForEachProfileFieldDefinition(profileName string, fn func(d config.FieldDefinition))

ForEachProfileFieldDefinition iterates the field definitions for the profile fields.

func GetActiveProfileAccountID

func GetActiveProfileAccountID() int

GetActiveProfileAccountID retrieves the currently configured account ID. When returning an account ID, the following will be evaluated in order, short-circuiting and returning the described value if true: 1. An environment variable override has been set with NEW_RELIC_ACCOUNT_ID 2. An account ID has been provided with the `--accountId` global flag 3. An account ID has been set in the active profile 4. The zero value will be returned if none of the above are true

func GetActiveProfileName

func GetActiveProfileName() string

GetActiveProfileName retrieves the profile in use for this command execution. To retrieve the active profile, the following criteria are evaluated in order, short circuiting and returning the described value if true: 1. a profile has been provided with the global `--profile` flag 2. a profile is set in the default profile config file 3. "default" is returned if none of the above are true

func GetActiveProfileString

func GetActiveProfileString(key config.FieldKey) string

GetActiveProfileString retrieves the value set for the given key in the active profile, if any. Environment variable overrides will be preferred over values set in the active profile, and a default value will be returned if it has been configured and no value has been set for the key in the active profile. An attempt will be made to convert the underlying value to a string if is not already stored that way. Failing the above, the zero value wil be returned.

func GetConfigFieldDefinition

func GetConfigFieldDefinition(key config.FieldKey) *config.FieldDefinition

GetConfigFieldDefinition retrieves the field definition for the given config key.

func GetConfigString

func GetConfigString(key config.FieldKey) string

GetConfigString retrieves the config value set for the given key, if any. Environment variable overrides will be preferred over values set in the given profile, and a default value will be returned if it has been configured and no value has been set for the key in the config file. An attempt will be made to convert the underlying value to a string if is not already stored that way. Failing the above, the zero value wil be returned.

func GetConfigTernary

func GetConfigTernary(key config.FieldKey) config.Ternary

GetConfigTernary retrieves the config value set for the given key, if any. Environment variable overrides will be preferred over values set in the given profile, and a default value will be returned if it has been configured and no value has been set for the key in the config file. An attempt will be made to convert the underlying value to a Ternary if is not already stored that way. Failing the above, the zero value wil be returned.

func GetDefaultProfileName

func GetDefaultProfileName() (string, error)

GetDefaultProfileName retrieves the profile set in the default profile config file. If the file does not exist, an empty string will be returned.

func GetLogLevel

func GetLogLevel() string

GetLogLevel retrieves the currently configured log level. When returning a log level, the following will be evaluated in order, short-circuiting and returning the described value if true: 1. An environment variable override has been set with NEW_RELIC_CLI_LOG_LEVEL 2. A log level has been provided with the `--trace` global flag 2. A log level has been provided with the `--debug` global flag 3. A log level has been set in the config file 4. If none of the above is true, the default log level will be returned.

func GetProfileInt

func GetProfileInt(profileName string, key config.FieldKey) int

GetProfileInt retrieves the value set for the given key and profile, if any. Environment variable overrides will be preferred over values set in the given profile, and a default value will be returned if it has been configured and no value has been set for the key in the given profile. An attempt will be made to convert the underlying value to an int if is not already stored that way. Failing the above, the zero value wil be returned.

func GetProfileNames

func GetProfileNames() []string

GetProfileNames retrieves all profile names currently configured in the credentials file.

func GetProfileString

func GetProfileString(profileName string, key config.FieldKey) string

GetProfileString retrieves the value set for the given key and profile, if any. Environment variable overrides will be preferred over values set in the given profile, and a default value will be returned if it has been configured and no value has been set for the key in the given profile. An attempt will be made to convert the underlying value to a string if is not already stored that way. Failing the above, the zero value wil be returned.

func GetValidConfigFieldKeys

func GetValidConfigFieldKeys() (fieldKeys []config.FieldKey)

GetValidConfigFieldKeys returns all the config field keys that can be set.

func RemoveProfile

func RemoveProfile(profileName string) error

RemoveProfile removes a profile from the credentials file. If the profile being removed is the default, it will attempt to find another profile to set as the new default. If another profile cannot be found, the default profile config file will be deleted.

func RequireActiveProfileAccountID

func RequireActiveProfileAccountID() int

RequireActiveProfileAccountID retrieves the currently configured account ID, returning an error if the value retrieved is the zero value. When returning an account ID, the following will be evaluated in order, short-circuiting and returning the described value if true: 1. An environment variable override has been set with NEW_RELIC_ACCOUNT_ID 2. An account ID has been provided with the `--accountId` global flag 3. An account ID has been set in the active profile

func SetConfigValue

func SetConfigValue(key config.FieldKey, value interface{}) error

SetConfigValue sets a config value for the given key.

func SetDefaultProfile

func SetDefaultProfile(profileName string) error

SetDefaultProfile sets the given profile as the new default in the default profile config file. If the given profile does not exist, the set operation will return an error.

func SetProfileValue

func SetProfileValue(profileName string, key config.FieldKey, value interface{}) error

SetProfileValue sets a value for the given key and profile.

Types

This section is empty.

Jump to

Keyboard shortcuts

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