config

package
v0.0.0-...-7241623 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAndBindFlag

func SetAndBindFlag(client *ConfigClient, name string, shorthand string, value any, description string) error

SetAndBindFlag sets and binds a flag to a command and viper.

Note these are some unsupported types: map[string]interface{}, map[string][]string, time.Time

Types

type Client

type Client[C schemas.BaseConfiguration] interface {
	GetConfig() C
	SetAndBindFlag(name string, shorthand string, value any, description string) error
}

Client interface

type ClientGetter

type ClientGetter struct{}

ClientGetter is an struct for getting a BB config client.

func (*ClientGetter) GetClient

func (clientGetter *ClientGetter) GetClient(command *cobra.Command, loggingClient *bbLog.Client, viperInstance *viper.Viper) (*ConfigClient, error)

GetClient returns a new config client.

type ConfigClient

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

ConfigClient is composed of functions to interact with configuration.

func NewClient

func NewClient(
	getConfig GetConfigFunc,
	setAndBindFlag SetAndBindFlagFunc,
	loggingClient *bbLog.Client,
	command *cobra.Command,
	viperInstance *viper.Viper,
) (*ConfigClient, error)

NewClient returns a new config client with the provided configuration

func (*ConfigClient) GetConfig

func (client *ConfigClient) GetConfig() (*schemas.GlobalConfiguration, error)

GetConfig returns the global configuration.

func (*ConfigClient) SetAndBindFlag

func (client *ConfigClient) SetAndBindFlag(name string, shorthand string, value any, description string) error

SetAndBindFlag sets and binds a flag to a command and viper.

type GetConfigFunc

type GetConfigFunc func(*ConfigClient) (*schemas.GlobalConfiguration, error)

GetConfigFunc type

type SetAndBindFlagFunc

type SetAndBindFlagFunc func(*ConfigClient, string, string, any, string) error

SetAndBindFlagFunc type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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