config

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName = "config.json"
	ConfigFileDir  = ".alpacon"

	// ServiceTokenPrefix is the default service-token key prefix, hard-coded here.
	// It matches the server's default SERVICE_TOKEN_PREFIX; if a self-hosted server
	// overrides that setting, its service tokens will not match this prefix and are
	// treated as generic tokens. Personal API tokens use "alpat-".
	ServiceTokenPrefix = "alpst-"
)

Variables

This section is empty.

Functions

func CreateConfig

func CreateConfig(workspaceURL, workspaceName, token, expiresAt, accessToken, refreshToken, baseDomain string, expiresIn int, insecure bool) error

func DeleteConfig

func DeleteConfig() error

func GetActiveWorkSession added in v1.4.6

func GetActiveWorkSession() (string, error)

GetActiveWorkSession returns the active work-session UUID for the current workspace. Returns "" (no error) when no session is set, the config is missing the map, or no config file exists.

func GetAuthMethod added in v1.4.8

func GetAuthMethod(cfg Config) string

GetAuthMethod returns a human-readable authentication method string for cfg.

func GetSmuxConfig added in v1.0.0

func GetSmuxConfig() *smux.Config

GetSmuxConfig returns a ready-to-use smux configuration.

func IsSaaS added in v1.4.2

func IsSaaS() (bool, error)

IsSaaS returns true if the workspace is an Alpacon Cloud (SaaS) deployment authenticated via Auth0. OnPrem deployments use a legacy API token and return false.

func IsServiceToken added in v1.7.4

func IsServiceToken(token string) bool

IsServiceToken reports whether token is a service token, identified by its key prefix. Service tokens are application principals and have no user profile.

func ResolveAuthMethod added in v1.4.8

func ResolveAuthMethod() string

ResolveAuthMethod loads config and returns the auth method string.

func SaveRefreshedAuth0Token

func SaveRefreshedAuth0Token(accessToken string, expiresIn int) error

func SetActiveWorkSession added in v1.4.6

func SetActiveWorkSession(uuid string) error

SetActiveWorkSession persists the work-session UUID for the current workspace. Pass "" to clear the entry for the current workspace.

func SwitchWorkspace added in v1.1.0

func SwitchWorkspace(newURL, newName string) error

SwitchWorkspace updates the workspace URL and name in the existing config.

Types

type Config

type Config struct {
	WorkspaceURL         string `json:"workspace_url"`
	WorkspaceName        string `json:"workspace_name"`
	Token                string `json:"token,omitempty"`
	ExpiresAt            string `json:"expires_at,omitempty"`
	AccessToken          string `json:"access_token,omitempty"`
	RefreshToken         string `json:"refresh_token,omitempty"`
	AccessTokenExpiresAt string `json:"access_token_expires_at,omitempty"`
	BaseDomain           string `json:"base_domain,omitempty"`
	Insecure             bool   `json:"insecure"`
	// ActiveWorkSessions maps workspace name to active work-session UUID.
	// Nil (not an empty map) when the key is absent from the JSON config file.
	ActiveWorkSessions map[string]string `json:"active_work_sessions,omitempty"`
}

Config describes the configuration for Alpacon CLI

func LoadConfig

func LoadConfig() (Config, error)

func (Config) IsMultiWorkspaceMode added in v1.1.0

func (c Config) IsMultiWorkspaceMode() bool

IsMultiWorkspaceMode returns true if the user logged in via Auth0 with a known base domain, enabling workspace listing and switching from the JWT.

func (Config) IsSaaS added in v1.4.2

func (c Config) IsSaaS() bool

Jump to

Keyboard shortcuts

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