Documentation
¶
Index ¶
- Constants
- func ConfigCommand(app Application, opts *ConfigCommandConfig) *cobra.Command
- func DefaultLogger(clioCfg Config, store redact.Store) (logger.Logger, error)
- func ExitEvent(interrupt bool) partybus.Event
- func VersionCommand(id Identification, additions ...versionAddition) *cobra.Command
- type Application
- type BusConstructor
- type Config
- type ConfigCommandConfig
- type DevelopmentConfig
- type FieldDescriber
- type FieldDescriptionSet
- type FlagAdder
- type FlagSet
- type Identification
- type Initializer
- type LoggerConstructor
- type LoggingConfig
- type PostLoader
- type PostRun
- type Profile
- type SetupConfig
- func (c *SetupConfig) WithBusConstructor(constructor BusConstructor) *SetupConfig
- func (c *SetupConfig) WithConfigFinders(finders ...fangs.Finder) *SetupConfig
- func (c *SetupConfig) WithConfigInRootHelp() *SetupConfig
- func (c *SetupConfig) WithDevelopmentConfig(cfg DevelopmentConfig) *SetupConfig
- func (c *SetupConfig) WithGlobalConfigFlag() *SetupConfig
- func (c *SetupConfig) WithGlobalLoggingFlags() *SetupConfig
- func (c *SetupConfig) WithInitializers(initializers ...Initializer) *SetupConfig
- func (c *SetupConfig) WithLoggerConstructor(constructor LoggerConstructor) *SetupConfig
- func (c *SetupConfig) WithLoggingConfig(cfg LoggingConfig) *SetupConfig
- func (c *SetupConfig) WithNoBus() *SetupConfig
- func (c *SetupConfig) WithNoLogging() *SetupConfig
- func (c *SetupConfig) WithPostRuns(postRuns ...PostRun) *SetupConfig
- func (c *SetupConfig) WithUI(uis ...UI) *SetupConfig
- func (c *SetupConfig) WithUIConstructor(constructor UIConstructor) *SetupConfig
- type State
- type UI
- type UICollection
- type UIConstructor
Constants ¶
const ExitEventType partybus.EventType = "clio-exit"
Variables ¶
This section is empty.
Functions ¶
func ConfigCommand ¶
func ConfigCommand(app Application, opts *ConfigCommandConfig) *cobra.Command
func VersionCommand ¶
func VersionCommand(id Identification, additions ...versionAddition) *cobra.Command
Types ¶
type Application ¶
type Application interface { ID() Identification AddFlags(flags *pflag.FlagSet, cfgs ...any) SetupCommand(cmd *cobra.Command, cfgs ...any) *cobra.Command SetupRootCommand(cmd *cobra.Command, cfgs ...any) *cobra.Command Run() }
func New ¶
func New(cfg SetupConfig) Application
type BusConstructor ¶
type BusConstructor func(Config) *partybus.Bus
type Config ¶
type Config struct { // Items that end up in the target application configuration Log *LoggingConfig `yaml:"log" json:"log" mapstructure:"log"` Dev *DevelopmentConfig `yaml:"dev" json:"dev" mapstructure:"dev"` // this is a list of all "config" objects from SetupCommand calls FromCommands []any `yaml:"-" json:"-" mapstructure:"-"` }
type ConfigCommandConfig ¶
type ConfigCommandConfig struct { LoadConfig bool IncludeLocationsSubcommand bool ReplaceHomeDirWithTilde bool }
func DefaultConfigCommandConfig ¶
func DefaultConfigCommandConfig() *ConfigCommandConfig
func (*ConfigCommandConfig) WithIncludeLocationsSubcommand ¶
func (c *ConfigCommandConfig) WithIncludeLocationsSubcommand(include bool) *ConfigCommandConfig
WithIncludeLocationsSubcommand true will include a `config locations` subcommand which lists each location that will be used to locate configuration files based on the configured environment
func (*ConfigCommandConfig) WithReplaceHomeDirWithTilde ¶
func (c *ConfigCommandConfig) WithReplaceHomeDirWithTilde(replace bool) *ConfigCommandConfig
WithReplaceHomeDirWithTilde adds a value filter function which replaces matching home directory values in strings starting with the user's home directory to make configurations more portable. Note: this does not apply to the locations subcommand, only the config command itself
type DevelopmentConfig ¶
type DevelopmentConfig struct {
Profile Profile `yaml:"profile" json:"profile" mapstructure:"profile"`
}
func (*DevelopmentConfig) DescribeFields ¶
func (d *DevelopmentConfig) DescribeFields(set fangs.FieldDescriptionSet)
func (*DevelopmentConfig) PostLoad ¶
func (d *DevelopmentConfig) PostLoad() error
type FieldDescriber ¶
type FieldDescriber interface {
DescribeFields(descriptions FieldDescriptionSet)
}
FieldDescriber a struct implementing this interface will have DescribeFields called when the config is summarized
type FieldDescriptionSet ¶
type FieldDescriptionSet = fangs.FieldDescriptionSet
FieldDescriptionSet FieldDescriber.DescribeFields will be called with this interface to add field descriptions
type FlagAdder ¶
type FlagAdder interface {
AddFlags(flags FlagSet)
}
FlagAdder interface can be implemented by structs in order to add flags when AddFlags is called
type FlagSet ¶
FlagSet is a facade of pflag.FlagSet, restricting the types of calls to what fangs needs
type Identification ¶
type Identification struct { Name string `json:"application,omitempty"` // application name Version string `json:"version,omitempty"` // application semantic version GitCommit string `json:"gitCommit,omitempty"` // git SHA at build-time GitDescription string `json:"gitDescription,omitempty"` // indication of git tree (either "clean" or "dirty") at build-time BuildDate string `json:"buildDate,omitempty"` // date of the build }
Identification defines the application name and version details (generally from build information)
type Initializer ¶
type LoggingConfig ¶
type LoggingConfig struct { Quiet bool `yaml:"quiet" json:"quiet" mapstructure:"quiet"` // -q, indicates to not show any status output to stderr Verbosity int `yaml:"-" json:"-" mapstructure:"verbosity"` // -v or -vv , controlling which UI (ETUI vs logging) and what the log level should be Level logger.Level `yaml:"level" json:"level" mapstructure:"level"` // the log level string hint FileLocation string `yaml:"file" json:"file" mapstructure:"file"` // the file path to write logs to // contains filtered or unexported fields }
LoggingConfig contains all logging-related configuration options available to the user via the application config.
func (*LoggingConfig) AddFlags ¶
func (l *LoggingConfig) AddFlags(flags fangs.FlagSet)
func (*LoggingConfig) DescribeFields ¶
func (l *LoggingConfig) DescribeFields(d fangs.FieldDescriptionSet)
func (*LoggingConfig) PostLoad ¶
func (l *LoggingConfig) PostLoad() error
type PostLoader ¶
type PostLoader = fangs.PostLoader
PostLoader is the interface used to do any sort of processing after the entire struct has been populated from the configuration files and environment variables
type SetupConfig ¶
type SetupConfig struct { // Metadata about the target application ID Identification // Default configuration items that end up in the target application configuration DefaultLoggingConfig *LoggingConfig DefaultDevelopmentConfig *DevelopmentConfig // Items required for setting up the application (clio-only configuration) FangsConfig fangs.Config BusConstructor BusConstructor LoggerConstructor LoggerConstructor UIConstructor UIConstructor Initializers []Initializer // contains filtered or unexported fields }
func NewSetupConfig ¶
func NewSetupConfig(id Identification) *SetupConfig
func (*SetupConfig) WithBusConstructor ¶
func (c *SetupConfig) WithBusConstructor(constructor BusConstructor) *SetupConfig
func (*SetupConfig) WithConfigFinders ¶
func (c *SetupConfig) WithConfigFinders(finders ...fangs.Finder) *SetupConfig
func (*SetupConfig) WithConfigInRootHelp ¶
func (c *SetupConfig) WithConfigInRootHelp() *SetupConfig
func (*SetupConfig) WithDevelopmentConfig ¶
func (c *SetupConfig) WithDevelopmentConfig(cfg DevelopmentConfig) *SetupConfig
func (*SetupConfig) WithGlobalConfigFlag ¶
func (c *SetupConfig) WithGlobalConfigFlag() *SetupConfig
WithGlobalConfigFlag adds the global `-c` / `--config` flags to the root command
func (*SetupConfig) WithGlobalLoggingFlags ¶
func (c *SetupConfig) WithGlobalLoggingFlags() *SetupConfig
WithGlobalLoggingFlags adds the global logging flags to the root command.
func (*SetupConfig) WithInitializers ¶
func (c *SetupConfig) WithInitializers(initializers ...Initializer) *SetupConfig
func (*SetupConfig) WithLoggerConstructor ¶
func (c *SetupConfig) WithLoggerConstructor(constructor LoggerConstructor) *SetupConfig
func (*SetupConfig) WithLoggingConfig ¶
func (c *SetupConfig) WithLoggingConfig(cfg LoggingConfig) *SetupConfig
func (*SetupConfig) WithNoBus ¶
func (c *SetupConfig) WithNoBus() *SetupConfig
func (*SetupConfig) WithNoLogging ¶
func (c *SetupConfig) WithNoLogging() *SetupConfig
func (*SetupConfig) WithPostRuns ¶
func (c *SetupConfig) WithPostRuns(postRuns ...PostRun) *SetupConfig
func (*SetupConfig) WithUI ¶
func (c *SetupConfig) WithUI(uis ...UI) *SetupConfig
func (*SetupConfig) WithUIConstructor ¶
func (c *SetupConfig) WithUIConstructor(constructor UIConstructor) *SetupConfig
type State ¶
type State struct { Config Config Bus *partybus.Bus Subscription *partybus.Subscription Logger logger.Logger RedactStore redact.Store UI *UICollection }
type UICollection ¶
type UICollection struct {
// contains filtered or unexported fields
}
func NewUICollection ¶
func NewUICollection(uis ...UI) *UICollection
func (UICollection) Handle ¶
func (u UICollection) Handle(event partybus.Event) error
func (*UICollection) Replace ¶
func (u *UICollection) Replace(uis ...UI) error
func (*UICollection) Setup ¶
func (u *UICollection) Setup(subscription partybus.Unsubscribable) error
func (*UICollection) Teardown ¶
func (u *UICollection) Teardown(force bool) error
type UIConstructor ¶
type UIConstructor func(Config) (*UICollection, error)