cli

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig[T Config](opts ...LoadConfigOption) (*T, error)

LoadConfig loads the config and resolves secrets using the specified options. No secret providers are registered by default; you must specify them via options. Example:

LoadConfig[MyConfigType](WithSecretProviders(providers.GcpProvider{}))
LoadConfig[MyConfigType](WithSecretProviders(providers.GcpProvider{}, providers.AwsProvider{}))

func SetupConfiguration

func SetupConfiguration(c *cobra.Command)

Types

type AppSettings

type AppSettings struct {
	Name        string
	Description string
	ConfigPath  string // Where this CLI config.yml?
	EnvPrefix   string // environment variable MYAPP_.....
	GitVersion  string
	GitRevision string
	LogLevel    string // Global log level for the app
}

type CLI

type CLI struct {
	// contains filtered or unexported fields
}

func New

func New[T Config](app AppSettings) *CLI

New generates a CLI instance

func (*CLI) Close

func (c *CLI) Close()

func (*CLI) GetRoot

func (c *CLI) GetRoot() *cobra.Command

func (*CLI) GetVersionString

func (c *CLI) GetVersionString() string

func (*CLI) Run

func (c *CLI) Run()

type CleanUpHandler

type CleanUpHandler func()

type Config

type Config interface {
	SetDefaults()
	Validate() error
}

type ConfigMock

type ConfigMock struct {
	Foo string `json:"foo"`
}

func (ConfigMock) SetDefaults

func (c ConfigMock) SetDefaults()

func (ConfigMock) Validate

func (c ConfigMock) Validate() error

type DefaultConfigHandler

type DefaultConfigHandler func()

type LoadConfigOption added in v0.22.0

type LoadConfigOption interface {
	// contains filtered or unexported methods
}

LoadConfigOption is a type-safe option for LoadConfig. Is on purpose not put just a function, because we want to avoid side effects.

func WithSecretProviders added in v0.22.0

func WithSecretProviders(providers ...secrets.SecretProvider) LoadConfigOption

WithSecretProviders registers the given secret providers for secret resolution. Pass this option to LoadConfig to specify which providers to use.

Jump to

Keyboard shortcuts

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