profile

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package profile provides commands for managing BindPlane profile configurations.

Index

Constants

View Source
const DefaultName string = "default"

DefaultName is the default profile name

Variables

This section is empty.

Functions

func Command

func Command(h Helper) *cobra.Command

Command returns the BindPlane profile cobra command.

func CurrentCommand

func CurrentCommand(h Helper) *cobra.Command

CurrentCommand returns the BindPlane profile current cobra command

func DeleteCommand

func DeleteCommand(h Helper) *cobra.Command

DeleteCommand returns the BindPlane profile delete cobra command

func GetCommand

func GetCommand(h Helper) *cobra.Command

GetCommand returns the BindPlane profile get cobra command

func ListCommand

func ListCommand(h Helper) *cobra.Command

ListCommand returns the BindPlane profile list cobra command

func SetCommand

func SetCommand(h Helper) *cobra.Command

SetCommand returns the BindPlane profile set cobra command

func UseCommand

func UseCommand(h Helper) *cobra.Command

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

func LoadFolder(profilesFolderPath string) Folder

LoadFolder returns an implementation of the profile.Folder interface and after ensuring that the folder exists and attempting to create it if necessary.

type Helper

type Helper interface {
	Folder() Folder

	Directory() string

	HomeFolderSetup() error
	// contains filtered or unexported methods
}

Helper TODO(doc)

func NewHelper

func NewHelper(bindplaneHomePath string) Helper

NewHelper TODO(doc)

Jump to

Keyboard shortcuts

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