Documentation ¶
Overview ¶
Package settings contains the logic for reading, writing, associating profiles with a user's settings file. It also configures a Phobos SDK client.
Index ¶
Constants ¶
const (
// DefaultProfileName is the name of the default profile
DefaultProfileName = "default"
)
Variables ¶
var ErrNoSettings = errors.New(noSettingsMessage)
ErrNoSettings is a special error if settings file does not exist.
Functions ¶
func DefaultCredentialsFilepath ¶
DefaultCredentialsFilepath returns the OS-dependent path/name of the default credentials file.
Types ¶
type Profile ¶
type Profile struct { Endpoint string `json:"endpoint"` // HTTP. TLSSkipVerify bool `json:"tlsSkipVerify"` // contains filtered or unexported fields }
Profile holds the contents of one profile from a settings file.
func (*Profile) NewClient ¶ added in v0.2.1
NewClient returns a Phobos client based on the specified profile.
func (*Profile) NewTokenGetter ¶ added in v0.2.1
NewTokenGetter creates a new token getter for the profile.
type Settings ¶
type Settings struct { Profiles map[string]Profile `json:"profiles"` CurrentProfile *Profile `json:"-"` // This field is not persistent, do not write it out. }
Settings holds the contents of one settings file and a pointer to the profile specified by the current command.
func ReadSettings ¶
ReadSettings reads the settings file. If no argument, it reads the default settings file: ~/.phobos/settings.json
func (*Settings) SetCurrentProfile ¶
SetCurrentProfile sets the current profile pointer in a settings object.
func (*Settings) WriteSettingsFile ¶
WriteSettingsFile writes the settings file. If no filename argument, it writes the default settings file: ~/.phobos/settings.json