Documentation ¶
Index ¶
- Constants
- func Command(h Helper) *cobra.Command
- func CurrentCommand(h Helper) *cobra.Command
- func DeleteCommand(h Helper) *cobra.Command
- func GetCommand(h Helper) *cobra.Command
- func ListCommand(h Helper) *cobra.Command
- func SetCommand(h Helper) *cobra.Command
- func UseCommand(h Helper) *cobra.Command
- type Folder
- type Helper
Constants ¶
const DefaultName string = "default"
DefaultName is the default profile name
Variables ¶
This section is empty.
Functions ¶
func CurrentCommand ¶
CurrentCommand returns the BindPlane profile current cobra command
func DeleteCommand ¶
DeleteCommand returns the BindPlane profile delete cobra command
func GetCommand ¶
GetCommand returns the BindPlane profile get cobra command
func ListCommand ¶
ListCommand returns the BindPlane profile list cobra command
func SetCommand ¶
SetCommand returns the BindPlane profile set cobra command
func UseCommand ¶
UseCommand returns the BindPlane profile use cobra command
Types ¶
type Folder ¶
type Folder interface { // Exists returns true if the profiles folder exists Exists() bool // ProfilesFolderPath returns the path to the folder of profiles which defaults to ~/.bindplane/profiles ProfilesFolderPath() string // CurrentProfilePath returns the full path of the current profile .yaml file CurrentProfilePath() (string, error) // CurrentProfileName returns the name of the current profile CurrentProfileName() (string, error) // SetCurrentProfileName changes the current profile name to a profile with the specified name. It returns an error if // a profile with that name doesn't exist or if the current profile could not be written. SetCurrentProfileName(name string) error // ProfileNames returns the names of the profiles. If we are unable to read the folder of profiles, an empty slice is // returned because there are no profiles that can be read. ProfileNames() []string // ProfilePath returns true if the profile file exists ProfilePath(name string) string // ProfileExists returns true if the profile file exists ProfileExists(name string) bool // ReadProfile reads and returns the profile with the specified name ReadProfile(name string) (*model.Profile, error) // WriteProfile writes a new profile with the specified name, overwriting an existing profiles with the same name. If // there is no current profile name, this profile will be set as the current profile. WriteProfile(profile *model.Profile) error // UpsertProfile creates or modifies a profile using ReadProfile and WriteProfile UpsertProfile(name string, updater func(*model.Profile) error) error // RemoveProfile deletes a profile with the specified name. If the profile doesn't exist, it does nothing. RemoveProfile(name string) error }
Folder manages the folder of profiles. There is a .yaml file for each profile with the name of the profile and there is a current file which is also yaml and contains a single `name: name` entry with the name of the current profile.
func LoadFolder ¶
LoadFolder returns an implementation of the profile.Folder interface and after ensuring that the folder exists and attempting to create it if necessary.