credentials

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultCredentialsFile is the default place to load profiles from
	DefaultCredentialsFile = "credentials"
)
View Source
const DefaultProfileFile = "default-profile"

DefaultProfileFile is the configuration file containing the default profile name

Variables

View Source
var Command = &cobra.Command{
	Use:   "profiles",
	Short: "Manage the credential profiles for this tool",
}

Command is the base command for managing profiles

Functions

func LoadDefaultProfile

func LoadDefaultProfile(configDir string) (string, error)

LoadDefaultProfile reads the profile name from the default profile file.

func LoadProfiles

func LoadProfiles(configDir string) (*map[string]Profile, error)

LoadProfiles reads the credential profiles from the default path.

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, region, apiKey string) 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
	Region string `mapstructure:"region" json:"region,omitempty"` // Region to use for New Relic resources
}

Profile contains data of a single profile

Jump to

Keyboard shortcuts

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