configuration

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package configuration provides configuration management for the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultConfigPath

func GetDefaultConfigPath() (string, error)

func ReadConfig

func ReadConfig(cmd *cobra.Command, expectedProfileType ProfileType, isLastStep ...bool) (*ResolvedProfile, *URLs, error)

func SetAPIEndpoint

func SetAPIEndpoint(endpoint string) error

Types

type ActiveConfig

type ActiveConfig struct {
	Profile string `toml:"profile"`
}

type BaseConfig

type BaseConfig struct {
	Endpoint string       `toml:"endpoint"`
	Output   OutputFormat `toml:"output"`
}

type Config

type Config struct {
	Default BaseConfig          `toml:"default"`
	Active  ActiveConfig        `toml:"active"`
	Profile map[string]*Profile `toml:"-"`

	ConfigPath string `toml:"-"`
	URLs       *URLs  `toml:"-"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func NewConfig

func NewConfig() *Config

func (*Config) CreateProfile

func (c *Config) CreateProfile(name string, profileType ProfileType, endpoint, apiKey string) error

func (*Config) DeleteProfile

func (c *Config) DeleteProfile(name string) error

func (*Config) GetActiveProfile

func (c *Config) GetActiveProfile() string

func (*Config) GetProfileWithUrls

func (c *Config) GetProfileWithUrls(profileName string) (*ResolvedProfile, *URLs, error)

func (*Config) ListProfiles

func (c *Config) ListProfiles() []string

func (*Config) LoadURL

func (c *Config) LoadURL(filePath string, envName string) (*URLs, error)

func (*Config) ResolveProfile

func (c *Config) ResolveProfile(profileName string) (*ResolvedProfile, error)

func (*Config) ResolveProfileAndURLs

func (c *Config) ResolveProfileAndURLs(cmd *cobra.Command, expectedProfileType ProfileType) (*ResolvedProfile, *URLs, error)

func (*Config) ResolveURLs

func (c *Config) ResolveURLs(profileName string) (*URLs, error)

func (*Config) SaveConfig

func (c *Config) SaveConfig() error

func (*Config) SetActiveProfile

func (c *Config) SetActiveProfile(profileName string) error

func (*Config) UpdateAPIKey

func (c *Config) UpdateAPIKey(name, apiKey string) error

func (*Config) UpdateProfile

func (c *Config) UpdateProfile(name, refreshToken string) error

func (*Config) ValidateProfile

func (c *Config) ValidateProfile(profileName string) error

type OutputFormat

type OutputFormat string
const (
	OutputJSON  OutputFormat = "json"
	OutputXML   OutputFormat = "xml"
	OutputYAML  OutputFormat = "yaml"
	OutputHuman OutputFormat = "human"
)

type Profile

type Profile struct {
	Inherits  string       `toml:"inherits,omitempty"`
	Type      ProfileType  `toml:"type"`
	Endpoint  string       `toml:"endpoint,omitempty"`
	Output    OutputFormat `toml:"output,omitempty"`
	APIKey    string       `toml:"api_key,omitempty"`
	UpdatedAt time.Time    `toml:"updated_at,omitempty"`
}

type ProfileType

type ProfileType string
const (
	ProfileTypeComposer ProfileType = "composer"
	ProfileTypeConsole  ProfileType = "console"
)

type ResolvedProfile

type ResolvedProfile struct {
	Name      string
	Type      ProfileType
	Endpoint  string
	Output    OutputFormat
	APIKey    string
	UpdatedAt time.Time
}

type URLs

type URLs struct {
	BaseURL string `yaml:"base_url"`
	IamURL  string `yaml:"iam"`
	DashURL string `yaml:"dash"`
	ChURL   string `yaml:"ch"`
}

func ConfigureAPIServerURL

func ConfigureAPIServerURL(endpoint string) (*URLs, error)

Jump to

Keyboard shortcuts

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