config

package
v0.1.98 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the path to the bce config directory (~/.bce).

func Save

func Save(cfg *Configuration) error

Save writes the configuration to disk atomically.

Types

type AuthMode

type AuthMode string

AuthMode identifies which credential strategy the profile uses.

const (
	ModeAK       AuthMode = "AK"
	ModeStsToken AuthMode = "StsToken"
)

type BceCredentials

type BceCredentials = auth.BceCredentials

BceCredentials is an alias so callers don't need to import bce-sdk-go/auth directly.

type Configuration

type Configuration struct {
	Current  string    `json:"current"`
	Profiles []Profile `json:"profiles"`
}

Configuration is the top-level structure persisted to ~/.bce/config.json.

func Load

func Load() (*Configuration, error)

Load reads the configuration file. Returns an empty config if the file does not exist.

func (*Configuration) GetProfile

func (cfg *Configuration) GetProfile(name string) *Profile

GetProfile looks up a profile by name. If name is empty the current profile is used.

func (*Configuration) SetProfile

func (cfg *Configuration) SetProfile(p Profile)

SetProfile upserts a profile into the configuration.

type FlagOverrides

type FlagOverrides struct {
	Region     string
	Endpoint   string
	Scheme     string // "http" or "https"; empty means auto-detect from product metadata
	Language   string
	Output     string
	Query      string
	DryRun     bool
	Debug      bool
	NoColor    bool
	Timeout    int  // request timeout in seconds; 0 means use default (15s)
	TotalCount int  // --total-count: cap on total items returned across pages; 0 = unlimited
	Pager      bool // --pager: enable auto-pagination and aggregate all pages
}

FlagOverrides carries per-invocation values from global flags that take precedence over the active profile.

type Profile

type Profile struct {
	Name            string   `json:"name"`
	Mode            AuthMode `json:"mode"`
	AccessKeyId     string   `json:"access_key_id,omitempty"`
	SecretAccessKey string   `json:"secret_access_key,omitempty"`
	SecurityToken   string   `json:"security_token,omitempty"`
	Region          string   `json:"region,omitempty"`
	Endpoint        string   `json:"endpoint,omitempty"`
	Language        string   `json:"language,omitempty"`
}

Profile holds all credential and preference settings for one named configuration.

func (*Profile) Credentials

func (p *Profile) Credentials() (*auth.BceCredentials, error)

Credentials returns BCE credentials for the profile's auth mode.

func (*Profile) Resolve

func (p *Profile) Resolve()

Resolve fills empty profile fields from standard environment variables.

Jump to

Keyboard shortcuts

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