config

package
v2.18.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 12 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

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) GetUser added in v2.18.7

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

GetUser returns the configured user 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 string, projects []UserProjectConfig, fetchedAt int64) error

SetUserProjects replaces the cached project list for the user identified by idOrEmail 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 — by non-empty Id or (case-insensitively) email — 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.

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"`
	// 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() (*UserConfig, error)

LoadDefaultUser returns the configured default user. 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