configuration

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration interface {
	// WriteTo writes an appropriate data
	// into a Properties
	//
	// Returns an error when something was wrong
	WriteTo(properties Properties) error
}

Configuration is an interface which describes a read configuration

func NewYamlConfiguration

func NewYamlConfiguration(content []byte) Configuration

NewYamlConfiguration creates a new YamlConfiguration

func ReadConfiguration added in v1.1.0

func ReadConfiguration(configFilepath string) (Configuration, error)

ReadConfiguration is a default method to read a Configuration by passed path

It reads, replaces env variables and returns parsed content as a new Configuration

Returns error when was not possible to open / read a file

This method exists only for simplification of Configuration's reading

If you want to have a better control over a configuration, just use everything you need manually

type ExpandEnvFileReader

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

ExpandEnvFileReader is an implementation of Reader which reads a Configuration from an os.File and replaces all "${ENV_VARIABLE_NAME}" mentions with real variable values

func (*ExpandEnvFileReader) Read

func (reader *ExpandEnvFileReader) Read(filepath string) (Configuration, error)

type InstanceCreator

type InstanceCreator interface {
	// Supports checks if an InstanceCreator supports
	// a content of passed format
	Supports(format string) bool

	// Create creates an instance of a Configuration
	//
	// Returns an error when something was wrong
	Create(content []byte) (Configuration, error)
}

InstanceCreator is an interface which provides a functionality to create an instance of a Configuration

func NewYamlInstanceCreator

func NewYamlInstanceCreator() InstanceCreator

NewYamlInstanceCreator creates a new YamlInstanceCreator

type Properties

type Properties interface {
	// GetPrefix returns a prefix in a Configuration
	// which defines a starting point of Properties
	GetPrefix() string
}

Properties is an interface which describes a separated part of a Configuration

type Reader

type Reader interface {
	// Read reads a Configuration from a file using
	// passed filepath
	//
	// Returns an error when something was wrong
	Read(filepath string) (Configuration, error)
}

Reader is an interface which provides a functionality for reading a Configuration from a file

func NewExpandEnvFileReader

func NewExpandEnvFileReader(instanceCreators []InstanceCreator) (Reader, error)

NewExpandEnvFileReader creates a new ExpandEnvFileReader

type Separator

type Separator interface {
	// Separate puts a part of Configuration
	// into passed Properties
	//
	// Returns an error when something was wrong
	Separate(config Configuration, properties Properties) error
}

Separator is an interface which provides a functionality to put a part of Configuration into passed Properties

func NewSimpleSeparator

func NewSimpleSeparator() Separator

NewSimpleSeparator creates a new SimpleSeparator

type SimpleSeparator

type SimpleSeparator struct {
}

SimpleSeparator a simple implementation of Separator

func (*SimpleSeparator) Separate

func (separator *SimpleSeparator) Separate(config Configuration, properties Properties) error

type YamlConfiguration

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

YamlConfiguration is an instance of Configuration which represents YAML configuration

func (*YamlConfiguration) WriteTo

func (configuration *YamlConfiguration) WriteTo(properties Properties) error

type YamlInstanceCreator

type YamlInstanceCreator struct {
}

YamlInstanceCreator is an instance of InstanceCreator which creates a YamlConfiguration

func (*YamlInstanceCreator) Create

func (creator *YamlInstanceCreator) Create(content []byte) (Configuration, error)

func (*YamlInstanceCreator) Supports

func (creator *YamlInstanceCreator) Supports(format string) bool

Jump to

Keyboard shortcuts

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