config

package
v1.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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyContextDefaults

func ApplyContextDefaults(cmd *cobra.Command) error

ApplyContextDefaults loads the stored config and sets default flag values from the current context, if not already provided.

func EnsureContext

func EnsureContext() error

EnsureContext creates and sets a default context if none exists.

func IsConfigFileExists

func IsConfigFileExists() bool

IsConfigFileExists checks if the configuration file exists

func NewConfigCmd added in v1.1.0

func NewConfigCmd() *cobra.Command

func SaveStoredConfig

func SaveStoredConfig(cfg *StoredConfig) error

SaveStoredConfig persists the configuration to disk

Types

type AddContextParams added in v0.17.0

type AddContextParams struct {
	Name         string
	ControlPlane string
	Credentials  string
	Namespace    string
	Project      string
	Component    string
}

AddContextParams defines parameters for adding a configuration context

func (AddContextParams) GetControlPlane added in v0.17.0

func (p AddContextParams) GetControlPlane() string

GetControlPlane returns the control plane name.

func (AddContextParams) GetCredentials added in v0.17.0

func (p AddContextParams) GetCredentials() string

GetCredentials returns the credentials name.

type AddControlPlaneParams added in v0.17.0

type AddControlPlaneParams struct {
	Name string
	URL  string
}

AddControlPlaneParams defines parameters for adding a control plane configuration

type AddCredentialsParams added in v0.17.0

type AddCredentialsParams struct {
	Name string
}

AddCredentialsParams defines parameters for adding credentials configuration

type Config added in v0.17.0

type Config struct{}

Config implements context-related commands.

func New added in v0.17.0

func New() *Config

New creates a new Config instance.

func (*Config) AddContext added in v0.17.0

func (c *Config) AddContext(params AddContextParams) error

AddContext creates a new configuration context.

func (*Config) AddControlPlane added in v0.17.0

func (c *Config) AddControlPlane(params AddControlPlaneParams) error

AddControlPlane adds a new control plane configuration.

func (*Config) AddCredentials added in v0.17.0

func (c *Config) AddCredentials(params AddCredentialsParams) error

AddCredentials adds a new credentials configuration.

func (*Config) DeleteContext added in v0.17.0

func (c *Config) DeleteContext(params DeleteContextParams) error

DeleteContext removes a configuration context by name.

func (*Config) DeleteControlPlane added in v0.17.0

func (c *Config) DeleteControlPlane(params DeleteControlPlaneParams) error

DeleteControlPlane removes a control plane configuration by name.

func (*Config) DeleteCredentials added in v0.17.0

func (c *Config) DeleteCredentials(params DeleteCredentialsParams) error

DeleteCredentials removes a credentials configuration by name.

func (*Config) ListContexts added in v0.17.0

func (c *Config) ListContexts() error

ListContexts prints all available contexts with their details.

func (*Config) ListControlPlanes added in v0.17.0

func (c *Config) ListControlPlanes() error

ListControlPlanes prints all control plane configurations.

func (*Config) ListCredentials added in v0.17.0

func (c *Config) ListCredentials() error

ListCredentials prints all credentials configurations.

func (*Config) UpdateContext added in v0.17.0

func (c *Config) UpdateContext(params UpdateContextParams) error

UpdateContext updates an existing configuration context.

func (*Config) UpdateControlPlane added in v0.17.0

func (c *Config) UpdateControlPlane(params UpdateControlPlaneParams) error

UpdateControlPlane updates an existing control plane configuration.

func (*Config) UseContext added in v0.17.0

func (c *Config) UseContext(params UseContextParams) error

UseContext sets the current context to the context with the given name.

type Context added in v0.17.0

type Context struct {
	Name         string `yaml:"name"`
	ControlPlane string `yaml:"controlplane"`          // Reference to controlplanes[].name
	Credentials  string `yaml:"credentials,omitempty"` // Reference to credentials[].name
	Namespace    string `yaml:"namespace,omitempty"`
	Project      string `yaml:"project,omitempty"`
	Component    string `yaml:"component,omitempty"`
}

Context represents a single named configuration context.

func GetCurrentContext added in v0.11.0

func GetCurrentContext() (*Context, error)

GetCurrentContext returns the current context

type ControlPlane added in v0.17.0

type ControlPlane struct {
	Name string `yaml:"name"`
	URL  string `yaml:"url"`
}

ControlPlane defines OpenChoreo API server configuration

func GetCurrentControlPlane added in v0.11.0

func GetCurrentControlPlane() (*ControlPlane, error)

GetCurrentControlPlane returns the control plane for the current context

type Credential added in v0.17.0

type Credential struct {
	Name         string `yaml:"name"`
	ClientID     string `yaml:"clientId,omitempty"`
	ClientSecret string `yaml:"clientSecret,omitempty"`
	Scope        string `yaml:"scope,omitempty"`
	Token        string `yaml:"token,omitempty"`
	RefreshToken string `yaml:"refreshToken,omitempty"`
	AuthMethod   string `yaml:"authMethod,omitempty"` // "pkce" or "client_credentials"
}

Credential represents authentication credentials

func GetCurrentCredential added in v0.11.0

func GetCurrentCredential() (*Credential, error)

GetCurrentCredential returns the credential for the current context

type DefaultContextValues

type DefaultContextValues struct {
	ContextName  string
	Namespace    string
	Project      string
	Credentials  string
	ControlPlane string
}

DefaultContextValues defines default values for context initialization

type DeleteContextParams added in v0.17.0

type DeleteContextParams struct {
	Name string
}

DeleteContextParams defines parameters for deleting a configuration context

type DeleteControlPlaneParams added in v0.17.0

type DeleteControlPlaneParams struct {
	Name string
}

DeleteControlPlaneParams defines parameters for deleting a control plane configuration

type DeleteCredentialsParams added in v0.17.0

type DeleteCredentialsParams struct {
	Name string
}

DeleteCredentialsParams defines parameters for deleting a credentials configuration

type StoredConfig added in v0.17.0

type StoredConfig struct {
	CurrentContext string         `yaml:"currentContext"`
	ControlPlanes  []ControlPlane `yaml:"controlplanes"`
	Credentials    []Credential   `yaml:"credentials,omitempty"`
	Contexts       []Context      `yaml:"contexts"`
}

StoredConfig is the structure to store configuration contexts.

func LoadStoredConfig

func LoadStoredConfig() (*StoredConfig, error)

LoadStoredConfig loads the configuration from disk

type UpdateContextParams added in v0.17.0

type UpdateContextParams struct {
	Name         string
	Namespace    string
	Project      string
	Component    string
	ControlPlane string
	Credentials  string
}

UpdateContextParams defines parameters for updating a configuration context

type UpdateControlPlaneParams added in v0.17.0

type UpdateControlPlaneParams struct {
	Name string
	URL  string
}

UpdateControlPlaneParams defines parameters for updating a control plane configuration

type UseContextParams added in v0.17.0

type UseContextParams struct {
	Name string
}

UseContextParams defines parameters for switching the current context

Jump to

Keyboard shortcuts

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