auth

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_VERS_URL_STR = "https://api.vers.sh"

Variables

This section is empty.

Functions

func GetAPIKey

func GetAPIKey() (string, error)

GetAPIKey retrieves the API key from environment variable or config file

func GetClientOptions

func GetClientOptions() ([]option.RequestOption, error)

GetClientOptions returns the options for the SDK client

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the path to the .versrc file in the user's home directory

func GetOrCreateSSHKey

func GetOrCreateSSHKey(vmID string, client *vers.Client, apiCtx context.Context) (string, error)

GetOrCreateSSHKey retrieves the path to an SSH key, fetching and saving it if necessary. It returns the path to the key file and an error if any occurred.

func GetVersUrl

func GetVersUrl() (*url.URL, error)

GetVersUrl returns the full URL with protocol validation

func HasAPIKey

func HasAPIKey() (bool, error)

HasAPIKey checks if an API key is present in environment variable or config file

func PromptForLogin

func PromptForLogin() error

PromptForLogin creates a helper function that checks for API key and prompts for login if not found

func SaveAPIKey

func SaveAPIKey(apiKey string) error

SaveAPIKey saves the API key to the config file

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig saves the configuration to the .versrc file

Types

type Config

type Config struct {
	APIKey string `json:"apiKey"`
}

Config represents the structure of the .versrc file

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from the .versrc file

type SSHKeyResponse added in v0.5.0

type SSHKeyResponse struct {
	SSHPrivateKey string `json:"ssh_private_key"`
	SSHPort       int    `json:"ssh_port"`
}

SSHKeyResponse represents the API response for VM SSH key

Jump to

Keyboard shortcuts

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