config

package
v0.0.0-...-6783019 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ListPrefix is the prefix for a list name
	ListPrefix = "$"
)

Variables

View Source
var (
	ErrConfigExistsAlready = errors.New("config item with same name already exists in set")
	ErrConfigNotFound      = errors.New("configuration item not found")
	ErrUnknownItemType     = errors.New("unknown item type for config item")
)
View Source
var (
	ItemTypeString = ItemType("string")
	ItemTypeInt    = ItemType("int")
	ItemTypeBool   = ItemType("bool")
)
View Source
var (
	ErrListNotFound = errors.New("list not found")
)

Functions

func ApplyToConfigSet

func ApplyToConfigSet(configPath string, cs ConfigurationSet) error

ApplyToConfigSet will apply the saved app configuration to the supplied config set.

func ApplyToConfigSetWithProvider

func ApplyToConfigSetWithProvider(configPath string, cs ConfigurationSet, provider string) error

ApplyToConfigSetWithProvider will apply the saved app configuration to the supplied config set and will take into consideration provider specific overrides

func GetValue

func GetValue(name string, provider string) (string, error)

func Unmarshall

func Unmarshall(cs ConfigurationSet, out interface{}) error

Unmarshall will unmarshall the ConfigurationSet into a struct

Types

type AppConfiguration

type AppConfiguration interface {
	Get() (*kconnectv1alpha.Configuration, error)
	Save(configuration *kconnectv1alpha.Configuration) error
	Parse(reader io.Reader) (*kconnectv1alpha.Configuration, error)
}

func NewAppConfiguration

func NewAppConfiguration() (AppConfiguration, error)

func NewAppConfigurationWithPath

func NewAppConfigurationWithPath(path string) (AppConfiguration, error)

type ConfigurationSet

type ConfigurationSet interface {
	Get(name string) *Item
	GetAll() []*Item
	Exists(name string) bool
	ExistsWithValue(name string) bool
	ValueIsList(name string) bool
	ValueString(name string) string
	Add(item *Item) error
	AddSet(set ConfigurationSet) error
	SetSensitive(name string) error
	SetHistoryIgnore(name string) error
	SetRequired(name string) error
	SetHidden(name string) error
	SetDeprecated(name string, message string) error
	SetValue(name string, value interface{}) error
	SetShort(name string, shorthand string) error

	String(name string, defaultValue string, description string) (*Item, error)
	Int(name string, defaultValue int, description string) (*Item, error)
	Bool(name string, defaultValue bool, description string) (*Item, error)
}

func NewConfigurationSet

func NewConfigurationSet() ConfigurationSet

type Item

type Item struct {
	Name              string
	Shorthand         string
	Type              ItemType
	Description       string
	Sensitive         bool
	ResolutionPrompt  string
	Value             interface{}
	DefaultValue      interface{}
	Required          bool
	Hidden            bool
	Deprecated        bool
	DeprecatedMessage string
	HistoryIgnore     bool
}

Item represents a configuration item

func (*Item) HasValue

func (i *Item) HasValue() bool

type ItemType

type ItemType string

Jump to

Keyboard shortcuts

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