Documentation
¶
Index ¶
- func ActiveInstanceAlias() string
- func ActiveProfileName() string
- func ApplyInstanceProfile(alias string) error
- func ApplyProfile(alias string) error
- func CheckAPIError(_ *cobra.Command, err error)
- func EffectiveCurrentProfileName() string
- func EffectiveInstanceForConfigUpdate(cmd *cobra.Command) string
- func EffectiveProfileForConfigUpdate(cmd *cobra.Command) string
- func Execute()
- func HandleError(cmd *cobra.Command, err error)
- func InstanceScopedPrefix() string
- func IsRefreshTokenExpired() (bool, error)
- func IsTokenExpired() (bool, error)
- func IsVerbose(level int) bool
- func ListInstanceAliases() []string
- func ListProfileNames() []string
- func LoadConfig() (apiKey, baseURL, apiVersion string, err error)
- func MergeProfileStorageRootForWrite() string
- func PrintErrorSummary(errorList []error)
- func ProfileScopedPrefix() string
- func Prompt(message string, mask bool) (string, error)
- func ReAuthenticate() error
- func RefreshAccessToken() error
- func ResolveActiveInstanceAlias(cmd *cobra.Command) string
- func ResolveActiveProfileName(cmd *cobra.Command) string
- func ResolveAndApplyInstance(cmd *cobra.Command) error
- func ResolveAndApplyProfile(cmd *cobra.Command) error
- func RetryableErrorHandler(_ *cobra.Command, err error, attempt int, maxAttempts int) bool
- func SetAPIFieldForInstance(field string, value interface{}, forInstance string)
- func SetAPIFieldForProfile(field string, value interface{}, forProfile string)
- func SetAuthFieldForInstance(field string, value interface{}, forInstance string)
- func SetAuthFieldForProfile(field string, value interface{}, forProfile string)
- func SetAuthViperKey(suffix string, value interface{})
- func SetTokenViperKey(suffix string, value interface{})
- func StoreToken(tokenResp *v2_2.AuthenticateResultModel, filePath string) error
- func UpdateConfig(cmd *cobra.Command) error
- func ValidateAndHandleErrors(_ *cobra.Command, data interface{})
- func ValidateAndRefreshToken() error
- type ConfigLoader
- type CustomURLResponse
- type TokenInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveInstanceAlias ¶
func ActiveInstanceAlias() string
ActiveInstanceAlias is kept for compatibility; use ActiveProfileName.
func ActiveProfileName ¶
func ActiveProfileName() string
ActiveProfileName returns the resolved profile name for the active command, if any.
func ApplyInstanceProfile ¶
ApplyInstanceProfile forwards to ApplyProfile (legacy name).
func ApplyProfile ¶
ApplyProfile merges profiles.<name>.{api,auth,token} (or legacy instances.<name>) into top-level keys.
func CheckAPIError ¶
CheckAPIError checks if an error is an API error and handles it appropriately
func EffectiveCurrentProfileName ¶
func EffectiveCurrentProfileName() string
EffectiveCurrentProfileName returns current_profile, or legacy current_instance.
func EffectiveInstanceForConfigUpdate ¶
EffectiveInstanceForConfigUpdate forwards to EffectiveProfileForConfigUpdate.
func EffectiveProfileForConfigUpdate ¶
EffectiveProfileForConfigUpdate resolves scope for config update: --for-profile, else active profile.
func HandleError ¶
HandleError handles errors in command execution
func InstanceScopedPrefix ¶
func InstanceScopedPrefix() string
InstanceScopedPrefix forwards to ProfileScopedPrefix.
func IsRefreshTokenExpired ¶
IsRefreshTokenExpired checks if the refresh token has expired
func IsTokenExpired ¶
IsTokenExpired checks if the access token has expired
func ListInstanceAliases ¶
func ListInstanceAliases() []string
ListInstanceAliases forwards to ListProfileNames.
func ListProfileNames ¶
func ListProfileNames() []string
ListProfileNames returns sorted profile names from profiles, or from instances if profiles is absent/empty.
func LoadConfig ¶
func MergeProfileStorageRootForWrite ¶
func MergeProfileStorageRootForWrite() string
MergeProfileStorageRootForWrite chooses "profiles" vs "instances" when adding a profile to an existing file.
func PrintErrorSummary ¶
func PrintErrorSummary(errorList []error)
PrintErrorSummary prints a summary of errors for batch operations
func ProfileScopedPrefix ¶
func ProfileScopedPrefix() string
ProfileScopedPrefix returns "profiles.<name>." or "instances.<name>." when a named profile is active.
func ReAuthenticate ¶
func ReAuthenticate() error
ReAuthenticate re-authenticates using stored email from config and prompts for password
func RefreshAccessToken ¶
func RefreshAccessToken() error
RefreshAccessToken refreshes the access token using the refresh token
func ResolveActiveInstanceAlias ¶
ResolveActiveInstanceAlias is kept for compatibility.
func ResolveActiveProfileName ¶
ResolveActiveProfileName resolves: --profile, then current_profile / CYVER_PROFILE, then legacy current_instance / CYVER_INSTANCE.
func ResolveAndApplyInstance ¶
ResolveAndApplyInstance forwards to ResolveAndApplyProfile.
func ResolveAndApplyProfile ¶
ResolveAndApplyProfile sets activeProfileResolved and merges the selected profile into top-level viper keys. If the resolved name is not present in the config (stale current_profile / CYVER_PROFILE / --profile), the CLI continues with top-level keys only and does not fail, so commands like config init still work.
func RetryableErrorHandler ¶
RetryableErrorHandler handles retryable errors with user feedback
func SetAPIFieldForInstance ¶
SetAPIFieldForInstance forwards to SetAPIFieldForProfile.
func SetAPIFieldForProfile ¶
SetAPIFieldForProfile sets api.<field> and, when forProfile is set, <root>.<name>.api.<field>.
func SetAuthFieldForInstance ¶
SetAuthFieldForInstance forwards to SetAuthFieldForProfile.
func SetAuthFieldForProfile ¶
SetAuthFieldForProfile sets auth.<field> and nested profile auth when applicable.
func SetAuthViperKey ¶
func SetAuthViperKey(suffix string, value interface{})
SetAuthViperKey writes auth fields under the active profile and mirrors to top-level auth.*.
func SetTokenViperKey ¶
func SetTokenViperKey(suffix string, value interface{})
SetTokenViperKey writes token fields under the active profile and mirrors to top-level token.*.
func StoreToken ¶
func StoreToken(tokenResp *v2_2.AuthenticateResultModel, filePath string) error
StoreToken saves the token response to a file with 0600 permissions
func UpdateConfig ¶
UpdateConfig applies changed flags from the update command to viper and writes the config file.
func ValidateAndHandleErrors ¶
ValidateAndHandleErrors validates input and handles any validation errors
func ValidateAndRefreshToken ¶
func ValidateAndRefreshToken() error
ValidateAndRefreshToken validates the current token and refreshes it if necessary
Types ¶
type ConfigLoader ¶
type ConfigLoader struct{}
LoadConfig loads and validates the configuration file using Viper. It returns an error if the config file is missing, inaccessible, or lacks required fields. It also automatically validates and refreshes tokens if necessary. ConfigLoader implements the shared.ConfigLoader interface
func (*ConfigLoader) LoadConfig ¶
func (c *ConfigLoader) LoadConfig() (apiKey, baseURL, apiVersion string, err error)
type CustomURLResponse ¶
type CustomURLResponse struct {
StatusCode int `json:"status_code"`
Headers map[string][]string `json:"headers"`
Body interface{} `json:"body"`
URL string `json:"url"`
Method string `json:"method"`
Duration string `json:"duration"`
}
CustomURLResponse represents the response structure for custom URL requests
func DirectHTTPRequest ¶
func DirectHTTPRequest(method, urlPath, data string) (*CustomURLResponse, error)
DirectHTTPRequest performs a direct HTTP request with the specified method, URL, and data
type TokenInfo ¶
type TokenInfo struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int32 `json:"expireInSeconds"`
RefreshExpiresIn int32 `json:"refresh_expires_in"`
TokenCreatedAt time.Time `json:"token_created_at"`
RefreshTokenCreatedAt time.Time `json:"refresh_token_created_at"`
}
TokenInfo represents token information stored in config