Documentation
¶
Index ¶
- Constants
- Variables
- func AddCommandsTo(rootCmd *cobra.Command)
- func ClearDefaults(cmd *cobra.Command, args []string, noColor bool) error
- func CreateProfile(cmd *cobra.Command, args []string, noColor bool) error
- func DeleteProfile(cmd *cobra.Command, args []string, noColor bool) error
- func ExportConfig(cmd *cobra.Command, args []string, noColor bool) error
- func GetConfigDir() (string, error)
- func GetConfigFilePath() (string, error)
- func GetDefault(cmd *cobra.Command, args []string, noColor bool) error
- func GetLoginFunc() func(context.Context) (*megaport.Client, error)
- func GetLoginFuncWithOutput() func(context.Context, string) (*megaport.Client, error)
- func GetNewUnauthenticatedClientFunc() func() (*megaport.Client, error)
- func ImportConfig(cmd *cobra.Command, args []string, noColor bool) error
- func ListProfiles(cmd *cobra.Command, args []string, noColor bool, outputFormat string) error
- func Login(ctx context.Context) (*megaport.Client, error)
- func LoginWithOutput(ctx context.Context, outputFormat string) (*megaport.Client, error)
- func NewUnauthenticatedClient() (*megaport.Client, error)
- func RemoveDefault(cmd *cobra.Command, args []string, noColor bool) error
- func SetDefault(cmd *cobra.Command, args []string, noColor bool) error
- func SetLoginFunc(fn func(context.Context) (*megaport.Client, error))
- func SetLoginFuncWithOutput(fn func(context.Context, string) (*megaport.Client, error))
- func SetNewUnauthenticatedClientFunc(fn func() (*megaport.Client, error))
- func UpdateProfile(cmd *cobra.Command, args []string, noColor bool) error
- func UseProfile(cmd *cobra.Command, args []string, noColor bool) error
- func ViewConfig(cmd *cobra.Command, args []string, noColor bool) error
- type ConfigFile
- type ConfigManager
- func (m *ConfigManager) ClearDefaults() error
- func (m *ConfigManager) CreateProfile(name, accessKey, secretKey, environment, description string) error
- func (m *ConfigManager) DeleteProfile(name string) error
- func (m *ConfigManager) Export() (*ConfigFile, error)
- func (m *ConfigManager) GetCurrentProfile() (*Profile, string, error)
- func (m *ConfigManager) GetDefault(key string) (interface{}, bool)
- func (m *ConfigManager) GetProfile(name string) (*Profile, error)
- func (m *ConfigManager) ListProfiles() (map[string]*Profile, error)
- func (m *ConfigManager) RemoveDefault(key string) error
- func (m *ConfigManager) Save() error
- func (m *ConfigManager) SetDefault(key string, value interface{}) error
- func (m *ConfigManager) UpdateProfile(name, accessKey, secretKey, environment string, updateDescription bool, ...) error
- func (m *ConfigManager) UseProfile(name string) error
- type Module
- type Profile
- type ProfileOutput
Constants ¶
const ConfigVersion = 1
ConfigVersion is the current version of the config file format
Variables ¶
var (
ErrProfileNotFound = errors.New("profile not found")
)
Functions ¶
func AddCommandsTo ¶
func GetConfigDir ¶
func GetConfigFilePath ¶
func GetLoginFunc ¶ added in v0.6.0
GetLoginFunc returns the current login function in a thread-safe manner.
func GetLoginFuncWithOutput ¶ added in v0.6.0
GetLoginFuncWithOutput returns the current output-aware login function in a thread-safe manner.
func GetNewUnauthenticatedClientFunc ¶ added in v0.6.0
GetNewUnauthenticatedClientFunc returns the current unauthenticated client factory in a thread-safe manner.
func ListProfiles ¶
func LoginWithOutput ¶ added in v0.4.7
func NewUnauthenticatedClient ¶ added in v0.5.9
NewUnauthenticatedClient creates an unauthenticated Megaport API client.
func SetLoginFunc ¶ added in v0.6.0
SetLoginFunc replaces the login function in a thread-safe manner.
func SetLoginFuncWithOutput ¶ added in v0.6.0
SetLoginFuncWithOutput replaces the output-aware login function in a thread-safe manner.
func SetNewUnauthenticatedClientFunc ¶ added in v0.6.0
SetNewUnauthenticatedClientFunc replaces the unauthenticated client factory in a thread-safe manner.
Types ¶
type ConfigFile ¶
type ConfigFile struct {
Version int `json:"version"`
ActiveProfile string `json:"activeProfile,omitempty"`
Profiles map[string]*Profile `json:"profiles,omitempty"`
Defaults map[string]interface{} `json:"defaults"`
}
ConfigFile represents the configuration file structure
func NewConfigFile ¶
func NewConfigFile() *ConfigFile
NewConfigFile creates a new empty configuration file
type ConfigManager ¶
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager handles configuration operations
func NewConfigManager ¶
func NewConfigManager() (*ConfigManager, error)
func (*ConfigManager) ClearDefaults ¶
func (m *ConfigManager) ClearDefaults() error
func (*ConfigManager) CreateProfile ¶
func (m *ConfigManager) CreateProfile(name, accessKey, secretKey, environment, description string) error
func (*ConfigManager) DeleteProfile ¶
func (m *ConfigManager) DeleteProfile(name string) error
func (*ConfigManager) Export ¶
func (m *ConfigManager) Export() (*ConfigFile, error)
func (*ConfigManager) GetCurrentProfile ¶
func (m *ConfigManager) GetCurrentProfile() (*Profile, string, error)
func (*ConfigManager) GetDefault ¶
func (m *ConfigManager) GetDefault(key string) (interface{}, bool)
func (*ConfigManager) GetProfile ¶ added in v0.5.4
func (m *ConfigManager) GetProfile(name string) (*Profile, error)
func (*ConfigManager) ListProfiles ¶
func (m *ConfigManager) ListProfiles() (map[string]*Profile, error)
func (*ConfigManager) RemoveDefault ¶
func (m *ConfigManager) RemoveDefault(key string) error
func (*ConfigManager) Save ¶
func (m *ConfigManager) Save() error
func (*ConfigManager) SetDefault ¶
func (m *ConfigManager) SetDefault(key string, value interface{}) error
func (*ConfigManager) UpdateProfile ¶
func (m *ConfigManager) UpdateProfile(name, accessKey, secretKey, environment string, updateDescription bool, description string) error
func (*ConfigManager) UseProfile ¶
func (m *ConfigManager) UseProfile(name string) error
type Profile ¶
type Profile struct {
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
Environment string `json:"environment"`
Description string `json:"description,omitempty"`
}
Profile represents a credential profile
type ProfileOutput ¶
type ProfileOutput struct {
output.Output `json:"-" header:"-"`
Name string `json:"name" header:"Name"`
AccessKey string `json:"access_key" header:"Access Key"`
Environment string `json:"environment" header:"Environment"`
Description string `json:"description" header:"Description"`
IsActive bool `json:"is_active" header:"Active"`
}