Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v2.19.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LiveKitTOMLFile = "livekit.toml"
)

Variables

View Source
var (
	ErrInvalidConfig       = errors.New("invalid configuration file")
	ErrInvalidReplicaCount = fmt.Errorf("replicas cannot be greater than max_replicas: %w", ErrInvalidConfig)
)

Functions

func ProjectNotFoundError added in v2.14.0

func ProjectNotFoundError(projects []ProjectConfig) error

func SameAPIURL added in v2.19.1

func SameAPIURL(a, b string) bool

SameAPIURL reports whether two Public API base URLs refer to the same API. Empty means the default Public API, and trailing slashes and case are ignored.

Types

type AgentTOML deprecated added in v2.4.7

type AgentTOML struct {
	ProjectSubdomain string `toml:"project_subdomain"`
}

Deprecated: use LiveKitTOML instead

type CLIConfig

type CLIConfig struct {
	DefaultProject string          `yaml:"default_project"`
	DefaultUser    string          `yaml:"default_user"`
	Projects       []ProjectConfig `yaml:"projects"`
	Users          []UserConfig    `yaml:"users"`
	DeviceName     string          `yaml:"device_name"`
	Theme          string          `yaml:"theme"`
	// contains filtered or unexported fields
}

func LoadOrCreate

func LoadOrCreate() (*CLIConfig, error)

LoadOrCreate loads config file from ~/.livekit/cli-config.yaml if it doesn't exist, it'll return an empty config file

func (*CLIConfig) FindUsers added in v2.19.1

func (c *CLIConfig) FindUsers(idOrEmail string) []*UserConfig

FindUsers returns the configured users matching idOrEmail (by id, or case-insensitively by email) on any Public API. The same person signed in to several APIs yields one entry per API. Use GetUser to resolve a user for a specific API. The returned pointers alias the slice elements.

func (*CLIConfig) GetUser added in v2.18.7

func (c *CLIConfig) GetUser(idOrEmail, apiURL string) *UserConfig

GetUser returns the configured user signed in to the Public API at apiURL matching idOrEmail (by id, or case-insensitively by email), or nil if none is configured. The returned pointer aliases the slice element, so mutations persist through a subsequent PersistIfNeeded on the same CLIConfig.

func (*CLIConfig) PersistIfNeeded

func (c *CLIConfig) PersistIfNeeded() error

func (*CLIConfig) PersistQuietly added in v2.18.7

func (c *CLIConfig) PersistQuietly() error

PersistQuietly writes the config without printing the "Saved CLI config" notice. Use it for background updates (e.g. refreshing the project cache) that shouldn't announce themselves — and must not pollute stdout/JSON output.

func (*CLIConfig) ProjectExists

func (c *CLIConfig) ProjectExists(name string) bool

func (*CLIConfig) RemoveProject

func (c *CLIConfig) RemoveProject(name string) error

func (*CLIConfig) SetUserProjects added in v2.18.7

func (c *CLIConfig) SetUserProjects(idOrEmail, apiURL string, projects []UserProjectConfig, fetchedAt int64) error

SetUserProjects replaces the cached project list for the user identified by idOrEmail on the Public API at apiURL and persists the config. fetchedAt is the Unix time the list was retrieved.

func (*CLIConfig) UpsertUser added in v2.18.7

func (c *CLIConfig) UpsertUser(u UserConfig) (stored *UserConfig, replaced bool)

UpsertUser stores u in the config. If a user matching the same person on the same Public API — by non-empty Id or (case-insensitively) email, plus APIURL — already exists, that entry is replaced outright rather than a duplicate being inserted; otherwise u is appended. It returns the stored user and whether an existing entry was replaced.

func (*CLIConfig) UsersForAPIURL added in v2.19.1

func (c *CLIConfig) UsersForAPIURL(apiURL string) []*UserConfig

UsersForAPIURL returns the configured users signed in to the Public API at apiURL. The returned pointers alias the slice elements.

type LiveKitTOML added in v2.4.7

type LiveKitTOML struct {
	Project *LiveKitTOMLProjectConfig `toml:"project"` // Required
	Agent   *LiveKitTOMLAgentConfig   `toml:"agent"`
}

func LoadTOMLFile added in v2.4.7

func LoadTOMLFile(dir string, tomlFileName string) (*LiveKitTOML, bool, error)

func NewLiveKitTOML added in v2.4.7

func NewLiveKitTOML(forSubdomain string) *LiveKitTOML

func (*LiveKitTOML) HasAgent added in v2.4.7

func (c *LiveKitTOML) HasAgent() bool

func (*LiveKitTOML) SaveTOMLFile added in v2.4.10

func (c *LiveKitTOML) SaveTOMLFile(dir string, tomlFileName string) error

func (*LiveKitTOML) WithDefaultAgent added in v2.4.7

func (c *LiveKitTOML) WithDefaultAgent() *LiveKitTOML

type LiveKitTOMLAgentConfig added in v2.4.7

type LiveKitTOMLAgentConfig struct {
	ID string `toml:"id"`
}

type LiveKitTOMLProjectConfig added in v2.4.7

type LiveKitTOMLProjectConfig struct {
	Subdomain string `toml:"subdomain"`
}

type ProjectConfig

type ProjectConfig struct {
	Name      string `yaml:"name"`
	ProjectId string `yaml:"project_id"`
	URL       string `yaml:"url"`
	APIKey    string `yaml:"api_key"`
	APISecret string `yaml:"api_secret"`
}

func LoadDefaultProject

func LoadDefaultProject() (*ProjectConfig, error)

func LoadProject

func LoadProject(name string) (*ProjectConfig, error)

func LoadProjectBySubdomain added in v2.4.0

func LoadProjectBySubdomain(subdomain string) (*ProjectConfig, error)

type UserConfig added in v2.18.7

type UserConfig struct {
	Id            string `yaml:"id"`
	Name          string `yaml:"name"`
	Email         string `yaml:"email"`
	SessionToken  string `yaml:"session_token"`
	SessionExpiry int64  `yaml:"session_expiry"`
	// APIURL is the Public API base URL the session was issued by (the
	// --public-api-url in effect at sign-in). A session is only valid
	// against that API, so the same person signed in to two environments (e.g.
	// staging and production) is stored as two entries. Empty means the default
	// Public API (entries written before this field existed).
	APIURL string `yaml:"api_url,omitempty"`
	// Projects caches the projects this user can access, as last fetched from
	// the Public API (listProjects). Caching lets project resolution avoid a
	// network round-trip on every command; ProjectsFetchedAt records the Unix
	// time it was populated so callers can refresh a stale cache.
	Projects          []UserProjectConfig `yaml:"projects,omitempty"`
	ProjectsFetchedAt int64               `yaml:"projects_fetched_at,omitempty"`
	// Workspaces caches the workspaces this user can access, mirroring Projects:
	// it lets workspace references resolve by name/alias offline, and
	// WorkspacesFetchedAt records when it was last populated.
	Workspaces          []UserWorkspaceConfig `yaml:"workspaces,omitempty"`
	WorkspacesFetchedAt int64                 `yaml:"workspaces_fetched_at,omitempty"`
}

func LoadDefaultUser added in v2.18.7

func LoadDefaultUser(apiURL string) (*UserConfig, error)

LoadDefaultUser returns the configured default user signed in to the Public API at apiURL. It mirrors LoadDefaultProject and is used by user-based (experimental) auth.

func (*UserConfig) FindProject added in v2.18.7

func (u *UserConfig) FindProject(ref string) *UserProjectConfig

FindProject returns the cached project matching ref by ProjectId or (case-insensitively) by Name/alias, or nil if none matches. Used to resolve the --project flag against the user's project cache in user-auth mode.

func (*UserConfig) FindWorkspace added in v2.18.7

func (u *UserConfig) FindWorkspace(ref string) *UserWorkspaceConfig

FindWorkspace resolves a workspace reference (id, name, or alias) against the cached workspaces, mirroring FindProject.

func (*UserConfig) SessionValid added in v2.18.7

func (u *UserConfig) SessionValid() bool

SessionValid reports whether the user has a session token that has not expired. A zero SessionExpiry means "no known expiry" and is treated as valid, so a manually-injected token without an expiry remains usable.

type UserProjectConfig added in v2.18.7

type UserProjectConfig struct {
	ProjectId string `yaml:"project_id" json:"id"`
	Name      string `yaml:"name,omitempty" json:"name,omitempty"`
	// Alias is a URL-safe handle derived from Name (deduplicated with a numeric
	// suffix), so a project can be referenced by a short, typeable name.
	Alias     string `yaml:"alias,omitempty" json:"alias,omitempty"`
	Subdomain string `yaml:"subdomain,omitempty" json:"subdomain,omitempty"`
	URL       string `yaml:"url,omitempty" json:"url,omitempty"`
}

UserProjectConfig is a project accessible under user-based auth. Unlike ProjectConfig it carries no API key/secret: requests are authorized with the user's session token and scoped to a project by id.

type UserWorkspaceConfig added in v2.18.7

type UserWorkspaceConfig struct {
	WorkspaceId string `yaml:"workspace_id" json:"id"`
	Name        string `yaml:"name,omitempty" json:"name,omitempty"`
	// Alias is a URL-safe handle derived from Name (deduplicated with a numeric
	// suffix), so a workspace can be referenced by a short, typeable name.
	Alias          string `yaml:"alias,omitempty" json:"alias,omitempty"`
	OrganizationId string `yaml:"organization_id,omitempty" json:"organizationId,omitempty"`
}

Jump to

Keyboard shortcuts

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