config

package
v0.0.0-...-ebf9046 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFingerprintDir

func GetFingerprintDir() (string, error)

GetFingerprintDir returns the directory for storing the platform fingerprint. On Linux, this uses /etc/pangolin since the fingerprint is machine-specific and needs to be written by a privileged process but readable by all users. On other platforms, it falls back to the user config directory.

func GetFingerprintFilePath

func GetFingerprintFilePath() (string, error)

GetFingerprintFilePath returns the full path to the platform fingerprint file.

func GetPangolinConfigDir

func GetPangolinConfigDir() (string, error)

GetPangolinConfigDir returns the path to the .pangolin directory and ensures it exists

func WithAccountStore

func WithAccountStore(ctx context.Context, store *AccountStore) context.Context

func WithConfig

func WithConfig(ctx context.Context, store *Config) context.Context

Types

type Account

type Account struct {
	UserID         string          `mapstructure:"userId" json:"userId"`
	Host           string          `mapstructure:"host" json:"host"`
	Email          string          `mapstructure:"email" json:"email"`
	Username       *string         `mapstructure:"username" json:"username,omitempty"`
	Name           *string         `mapstructure:"name" json:"name,omitempty"`
	SessionToken   string          `mapstructure:"sessionToken" json:"sessionToken"`
	OrgID          string          `mapstructure:"orgId" json:"orgId,omitempty"`
	OlmCredentials *OlmCredentials `mapstructure:"olmCredentials" json:"olmCredentials,omitempty"`
	ServerInfo     *ServerInfo     `mapstructure:"serverInfo" json:"serverInfo,omitempty"`
}

type AccountStore

type AccountStore struct {
	ActiveUserID string             `mapstructure:"activeUserId" json:"activeUserId"`
	Accounts     map[string]Account `mapstructure:"accounts" json:"accounts"`
	// contains filtered or unexported fields
}

func AccountStoreFromContext

func AccountStoreFromContext(ctx context.Context) *AccountStore

func LoadAccountStore

func LoadAccountStore() (*AccountStore, error)

func (*AccountStore) ActiveAccount

func (s *AccountStore) ActiveAccount() (*Account, error)

func (*AccountStore) AvailableAccounts

func (s *AccountStore) AvailableAccounts() []Account

Return a list of accounts that are available to use. These accounts are guaranteed to have a valid session token.

func (*AccountStore) Deactivate

func (s *AccountStore) Deactivate(userID string) error

Set account with the user ID as "inactive"; keeps the Olm credentials for the account, but clear other account state like the session token and selected org ID.

This effectively logs out the account.

func (*AccountStore) Save

func (s *AccountStore) Save() error

func (*AccountStore) UpdateAccountUserInfo

func (s *AccountStore) UpdateAccountUserInfo(userID, username, name string) error

UpdateAccountUserInfo updates the username and name for a specific account

func (*AccountStore) UpdateActiveAccount

func (s *AccountStore) UpdateActiveAccount(account *Account) error

UpdateActiveAccount updates the active account in the store. This must be called after modifying an account obtained from ActiveAccount() because Go maps return copies of values, not references.

type Config

type Config struct {
	LogLevel           logger.LogLevel `mapstructure:"log_level" json:"log_level"`
	LogFile            string          `mapstructure:"log_file" json:"log_file"`
	DisableUpdateCheck bool            `mapstructure:"disable_update_check" json:"disable_update_check"`
	// contains filtered or unexported fields
}

func ConfigFromContext

func ConfigFromContext(ctx context.Context) *Config

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) Save

func (c *Config) Save() error

func (*Config) Validate

func (c *Config) Validate() error

type OlmCredentials

type OlmCredentials struct {
	ID     string `mapstructure:"id" json:"id"`
	Secret string `mapstructure:"secret" json:"secret"`
}

type ServerInfo

type ServerInfo struct {
	Version                string  `mapstructure:"version" json:"version"`
	SupporterStatusValid   bool    `mapstructure:"supporterStatusValid" json:"supporterStatusValid"`
	Build                  string  `mapstructure:"build" json:"build"` // "oss" | "enterprise" | "saas"
	EnterpriseLicenseValid bool    `mapstructure:"enterpriseLicenseValid" json:"enterpriseLicenseValid"`
	EnterpriseLicenseType  *string `mapstructure:"enterpriseLicenseType" json:"enterpriseLicenseType,omitempty"`
}

ServerInfo represents server information including version, build type, and license status This mirrors api.ServerInfo to avoid import cycles

Jump to

Keyboard shortcuts

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