configuration

package
v1.6.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 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, organizationID 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 ConfigInterface

type ConfigInterface interface {
	ResolveProfileAndURLs(cmd *cobra.Command, expectedProfileType ProfileType) (*ResolvedProfile, *URLs, error)
}

ConfigInterface defines the interface for configuration to enable mocking

type MockConfig

type MockConfig struct {
	ResolvedProfile *ResolvedProfile
	Urls            *URLs
	Err             error
}

MockConfig implements ConfigInterface for testing

func NewMockConfig

func NewMockConfig(profile ProfileType, apiKey, orgID string) *MockConfig

func (*MockConfig) ResolveProfileAndURLs

func (m *MockConfig) ResolveProfileAndURLs(cmd *cobra.Command, expectedProfileType ProfileType) (*ResolvedProfile, *URLs, 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"`
	URLs           *URLs        `toml:"urls,omitempty"`
	OrganizationID string       `toml:"organization_id,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
	URLs           *URLs
	OrganizationID string
}

type URLs

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

func ConfigureAPIServerURL

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

func NewURLs

func NewURLs(
	baseURL, iamURL, dashURL, chURL string,
) URLs

Jump to

Keyboard shortcuts

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