config

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package config loads and persists the CLI configuration in ~/.volcano/config.json.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAuthenticated indicates no token is configured for cloud API calls.
	ErrNotAuthenticated = errors.New("not authenticated. Run 'volcano login' first")
	// ErrNoProjectSelected indicates no active project is configured for project-scoped cloud API calls.
	ErrNoProjectSelected = errors.New("no project selected. Run 'volcano use <project-name>' or set VOLCANO_PROJECT_ID")
)

Functions

func Delete

func Delete() error

Delete removes ~/.volcano/config.json. A missing file is considered success.

func FirstPartyDeviceClientID

func FirstPartyDeviceClientID() (string, error)

FirstPartyDeviceClientID resolves the first-party OAuth device client ID.

func FunctionAliasScope added in v0.0.4

func FunctionAliasScope(apiURL, projectID string) string

FunctionAliasScope returns the config key for aliases bound to one API URL and project ID. The API URL is trimmed so trailing slashes do not split scopes.

func Path

func Path() (string, error)

Path returns the default on-disk config path.

Types

type Config

type Config struct {
	// APIBaseURL overrides the compiled API URL for synthetic command configs.
	// It is intentionally not persisted to the user's cloud config file.
	APIBaseURL     string         `json:"-"`
	UserToken      string         `json:"user_token,omitempty"`
	UserID         string         `json:"user_id,omitempty"`
	AnonKey        string         `json:"-"`
	ServiceKey     string         `json:"-"`
	CurrentProject *ProjectConfig `json:"current_project,omitempty"`
	// FunctionAliases stores per-user function invoke aliases by API URL and
	// project ID scope. Scope keys are produced by FunctionAliasScope.
	FunctionAliases map[string]map[string]string `json:"function_aliases,omitempty"`
	// DocsSource persists a non-default documentation source override so that
	// `volcano docs` commands resolve the same repo/ref/path across invocations
	// without repeating --repo/--ref/--path flags. Nil means "use the compiled
	// default source".
	DocsSource *DocsSourceConfig `json:"docs_source,omitempty"`
	// IgnoreEnv disables environment overrides for synthetic command configs.
	IgnoreEnv bool `json:"-"`
}

Config represents the CLI configuration stored in ~/.volcano/config.json.

func Default

func Default() *Config

Default returns an empty config.

func Load

func Load() (*Config, error)

Load reads ~/.volcano/config.json. Missing config is not an error.

func (*Config) APIURL

func (c *Config) APIURL() string

APIURL returns the API URL with VOLCANO_API_URL taking precedence unless env overrides are disabled. Precedence: env > runtime override (APIBaseURL) > compiled default.

func (*Config) DeleteFunctionAlias added in v0.0.4

func (c *Config) DeleteFunctionAlias(scope, alias string) bool

DeleteFunctionAlias removes alias from the given scope and reports whether it existed.

func (*Config) FunctionAlias added in v0.0.4

func (c *Config) FunctionAlias(scope, alias string) (string, bool)

FunctionAlias returns the function ID configured for alias in the given scope.

func (*Config) FunctionInvokeToken added in v0.0.4

func (c *Config) FunctionInvokeToken() string

FunctionInvokeToken returns the token used for runtime function invocation. Local mode supplies service and anon keys for invoke endpoints; cloud falls back to the normal configured token until a project invoke key is available.

func (*Config) ProjectID

func (c *Config) ProjectID() string

ProjectID returns the current project ID, with VOLCANO_PROJECT_ID taking precedence unless env overrides are disabled.

func (*Config) RequireAuth

func (c *Config) RequireAuth() error

RequireAuth returns an old-CLI-compatible error when no token is available.

func (*Config) RequireProject

func (c *Config) RequireProject() error

RequireProject returns an old-CLI-compatible error when no project is selected.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to ~/.volcano/config.json with owner-only permissions.

func (*Config) SetFunctionAlias added in v0.0.4

func (c *Config) SetFunctionAlias(scope, alias, functionID string)

SetFunctionAlias stores alias in the given scope.

func (*Config) Token

func (c *Config) Token() string

Token returns the configured token, with VOLCANO_TOKEN taking precedence unless env overrides are disabled.

func (*Config) WebURL added in v0.0.4

func (c *Config) WebURL() string

WebURL returns the Volcano web URL with VOLCANO_WEB_URL taking precedence.

func (*Config) WebURLOverride added in v0.0.4

func (c *Config) WebURLOverride() (string, bool)

WebURLOverride returns an explicit VOLCANO_WEB_URL value when one is set, reporting false otherwise. Callers that derive the web origin from another source (e.g. the device-flow verification URI) use this to let an explicit override win without mistaking the compiled default for an override.

type DocsSourceConfig added in v0.1.0

type DocsSourceConfig struct {
	Repo string `json:"repo,omitempty"`
	Ref  string `json:"ref,omitempty"`
	Path string `json:"path,omitempty"`
}

DocsSourceConfig persists a documentation source override. Empty fields fall back to the compiled defaults during resolution.

type ProjectConfig

type ProjectConfig struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

ProjectConfig represents the currently selected Volcano project.

Jump to

Keyboard shortcuts

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