utils

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSudoRequired = errors.New("Please rerun this command as sudo. This is a one time thing for Pangolin to setup your machine.")

ErrSudoRequired is returned when the user needs to run the command as sudo for first-time setup

Functions

func AccountDisplayName

func AccountDisplayName(account *config.Account) string

AccountDisplayName returns a display name for an account with precedence: email > name > username > "Account"

func AccountDisplayNameWithHost

func AccountDisplayNameWithHost(account *config.Account) string

AccountDisplayNameWithHost returns a display name for an account with hostname suffix when multiple accounts might share the same email. Format: "displayName @ hostname"

func CheckBlockedBeforeConnect

func CheckBlockedBeforeConnect(client *api.Client, account *config.Account) error

CheckBlockedBeforeConnect checks if the OLM is blocked before attempting to connect. This should only be called when the user attempts to connect, not during authentication. Returns an error if the account is blocked. If the check fails (network error, etc.), returns an error that the caller should log but allow the connection attempt to proceed (the server will reject if truly blocked).

func EnsureOlmCredentials

func EnsureOlmCredentials(client *api.Client, account *config.Account) (bool, error)

EnsureOlmCredentials ensures that OLM credentials exist and are valid. It checks if OLM credentials exist locally, verifies them on the server, and creates new ones if they don't exist or are invalid.

If new ones are created, a "true" is returned to indicate we need to save the new credentials to disk.

func EnsureOrgAccess

func EnsureOrgAccess(client *api.Client, account *config.Account) error

EnsureOrgAccess ensures that the user has access to the organization

func FormatHostnameBaseURL

func FormatHostnameBaseURL(hostname string) string

FormatHostnameBaseURL returns the hostname formatted as a base URL (with protocol, without /api/v1). This is useful for constructing URLs to the web interface.

func PrintTable

func PrintTable(headers []string, rows [][]string)

PrintTable prints a column-aligned plain-text table minwidth=0, tabwidth=8, padding=2, padchar=' ', flags=0

func SelectOrgForm

func SelectOrgForm(client *api.Client, userID string) (string, error)

SelectOrgForm lists organizations for a user and prompts them to select one. It returns the selected org ID and any error. If the user has only one organization, it's automatically selected.

func SwitchActiveClientOrg

func SwitchActiveClientOrg(orgID string) bool

SwitchActiveClientOrg checks if the OLM client is running and switches to the new org if so It returns true if a switch was attempted (regardless of success)

func UserDisplayName

func UserDisplayName(user *api.User) string

UserDisplayName returns a display name for a user with precedence: email > name > username > "User"

Types

This section is empty.

Jump to

Keyboard shortcuts

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