properties

package
v1.1.33 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSecretReference = errors.Newf(1411, "invalid secret reference - %s, please check the value for %s config")

ErrInvalidSecretReference - Error for parsing properties with secret reference

Functions

func GetAliasKeyPrefix

func GetAliasKeyPrefix() string

GetAliasKeyPrefix -

func SetAliasKeyPrefix

func SetAliasKeyPrefix(keyPrefix string)

SetAliasKeyPrefix -

Types

type DurationOpt

type DurationOpt func(prop *properties)

DurationOpt are duration range options passed into AddDurationProperty

func WithLowerLimit

func WithLowerLimit(lowerLimit time.Duration) DurationOpt

WithLowerLimit - lower limit of the duration range

func WithUpperLimit

func WithUpperLimit(upperLimit time.Duration) DurationOpt

WithUpperLimit - upper limit of the duration range

type Properties

type Properties interface {
	// Methods for adding yaml properties and command flag
	AddStringProperty(name string, defaultVal string, description string)
	AddStringPersistentFlag(name string, defaultVal string, description string)
	AddStringFlag(name string, description string)
	AddDurationProperty(name string, defaultVal time.Duration, description string, options ...DurationOpt)
	AddIntProperty(name string, defaultVal int, description string)
	AddBoolProperty(name string, defaultVal bool, description string)
	AddBoolFlag(name, description string)
	AddStringSliceProperty(name string, defaultVal []string, description string)
	AddObjectSliceProperty(name string, objectPropertyNames []string)

	// Methods to get the configured properties
	StringPropertyValue(name string) string
	StringFlagValue(name string) (bool, string)
	DurationPropertyValue(name string) time.Duration
	IntPropertyValue(name string) int
	BoolPropertyValue(name string) bool
	BoolPropertyValueOrTrue(name string) bool // Use this method when the default value, no config given, is true
	BoolFlagValue(name string) bool
	StringSlicePropertyValue(name string) []string
	ObjectSlicePropertyValue(name string) []map[string]interface{}

	// Methods to set a property
	SetStringFlagValue(name string, value string)

	// Log Properties
	MaskValues(name string)
	DebugLogProperties()
	SetAliasKeyPrefix(aliasKeyPrefix string)
}

Properties - Root Command Properties interface for all configs to use for adding and parsing values

func NewProperties

func NewProperties(rootCmd *cobra.Command) Properties

NewProperties - Creates a new Properties struct

func NewPropertiesWithSecretResolver

func NewPropertiesWithSecretResolver(rootCmd *cobra.Command, secretResolver SecretPropertyResolver) Properties

NewPropertiesWithSecretResolver - Creates a new Properties struct with secret resolver for string property/flag

type SecretPropertyResolver

type SecretPropertyResolver interface {
	ResolveSecret(secretRef string) (string, error)
}

SecretPropertyResolver - interface for resolving property values with secret references

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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