config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 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 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"`
	CurrentProject *ProjectConfig `json:"current_project,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) 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) Token

func (c *Config) Token() string

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

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