Documentation ¶
Index ¶
- Constants
- Variables
- func LoadDefaultProfile(configDir string) (string, error)
- func LoadProfiles(configDir string) (*map[string]Profile, error)
- func SetDefaultProfile(p Profile)
- func StringToRegionHookFunc() mapstructure.DecodeHookFunc
- func WithCredentials(f func(c *Credentials))
- func WithCredentialsFrom(configDir string, f func(c *Credentials))
- type Credentials
- type Profile
Constants ¶
const (
// DefaultCredentialsFile is the default place to load profiles from
DefaultCredentialsFile = "credentials"
)
const DefaultProfileFile = "default-profile"
DefaultProfileFile is the configuration file containing the default profile name
Variables ¶
var Command = &cobra.Command{ Use: "profile", Short: "Manage the authentication profiles for this tool", Aliases: []string{ "profiles", }, }
Command is the base command for managing profiles
Functions ¶
func LoadDefaultProfile ¶
LoadDefaultProfile reads the profile name from the default profile file.
func LoadProfiles ¶
LoadProfiles reads the credential profiles from the default path.
func SetDefaultProfile ¶ added in v0.8.11
func SetDefaultProfile(p Profile)
SetDefaultProfile allows mocking of the default profile for testing purposes.
func StringToRegionHookFunc ¶ added in v0.6.2
func StringToRegionHookFunc() mapstructure.DecodeHookFunc
StringToRegionHookFunc takes a string and runs it through the region parser to create a valid region (or error)
func WithCredentials ¶
func WithCredentials(f func(c *Credentials))
WithCredentials loads and returns the CLI credentials.
func WithCredentialsFrom ¶
func WithCredentialsFrom(configDir string, f func(c *Credentials))
WithCredentialsFrom loads and returns the CLI credentials from a specified location.
Types ¶
type Credentials ¶
type Credentials struct { DefaultProfile string Profiles map[string]Profile ConfigDirectory string }
Credentials is the metadata around all configured profiles
func LoadCredentials ¶
func LoadCredentials(configDir string) (*Credentials, error)
LoadCredentials loads the current CLI credentials from disk.
func (*Credentials) AddProfile ¶
func (c *Credentials) AddProfile(profileName string, p Profile) error
AddProfile adds a new profile to the credentials file.
func (*Credentials) Default ¶
func (c *Credentials) Default() *Profile
Default returns the default profile
func (*Credentials) List ¶
func (c *Credentials) List()
List outputs a list of all the configured Credentials
func (*Credentials) RemoveProfile ¶
func (c *Credentials) RemoveProfile(profileName string) error
RemoveProfile removes an existing profile from the credentials file.
func (*Credentials) SetDefaultProfile ¶
func (c *Credentials) SetDefaultProfile(profileName string) error
SetDefaultProfile modifies the profile name to use by default.
type Profile ¶
type Profile struct { APIKey string `mapstructure:"apiKey" json:"apiKey,omitempty"` // For accessing New Relic GraphQL resources InsightsInsertKey string `mapstructure:"insightsInsertKey" json:"insightsInsertKey,omitempty"` // For posting custom events Region string `mapstructure:"region" json:"region,omitempty"` // Region to use for New Relic resources AccountID int `mapstructure:"accountID" json:"accountID,omitempty"` // AccountID to use for New Relic resources LicenseKey string `mapstructure:"licenseKey" json:"licenseKey,omitempty"` // License key to use for agent config and ingest }
Profile contains data of a single profile
func DefaultProfile ¶ added in v0.8.11
func DefaultProfile() *Profile
DefaultProfile retrieves the current default profile.
func (Profile) MarshalJSON ¶ added in v0.6.1
MarshalJSON allows us to override the default behavior on marshal and lowercase the region string for backwards compatibility