environment

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package environment defines object describing the current environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEnvironmentVariables

func ValidateEnvironmentVariables(vars ...IEnvironmentVariable) error

ValidateEnvironmentVariables validates that environment variables are correctly defined in regard to their schema.

Types

type EnvVar

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

func (*EnvVar) Equal

func (e *EnvVar) Equal(v IEnvironmentVariable) bool

func (*EnvVar) GetKey

func (e *EnvVar) GetKey() string

func (*EnvVar) GetValue

func (e *EnvVar) GetValue() string

func (*EnvVar) MarshalText

func (e *EnvVar) MarshalText() (text []byte, err error)

func (*EnvVar) String

func (e *EnvVar) String() string

func (*EnvVar) UnmarshalText

func (e *EnvVar) UnmarshalText(text []byte) error

func (*EnvVar) Validate

func (e *EnvVar) Validate() (err error)

type IEnvironment

type IEnvironment interface {
	// GetCurrentUser returns the environment current user.
	GetCurrentUser() *user.User
	// GetEnvironmentVariables returns the variables defining the environment.
	GetEnvironmentVariables() []IEnvironmentVariable
	// GetFilesystem returns the filesystem associated with the current environment
	GetFilesystem() filesystem.FS
}

IEnvironment defines an environment for an application to run on.

func NewCurrentEnvironment

func NewCurrentEnvironment() IEnvironment

NewCurrentEnvironment returns system current environment.

type IEnvironmentVariable

type IEnvironmentVariable interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
	fmt.Stringer
	// GetKey returns the variable key.
	GetKey() string
	// GetValue returns the variable value.
	GetValue() string
	// Validate checks whether the variable value is correctly defined
	Validate() error
	// Equal states whether two environment variables are equal or not.
	Equal(v IEnvironmentVariable) bool
}

IEnvironmentVariable defines an environment variable to be set for the commands to run.

func NewEnvironmentVariable

func NewEnvironmentVariable(key, value string) IEnvironmentVariable

NewEnvironmentVariable returns an environment variable defined by a key and a value.

func NewEnvironmentVariableWithValidation

func NewEnvironmentVariableWithValidation(key, value string, rules ...validation.Rule) IEnvironmentVariable

NewEnvironmentVariableWithValidation returns an environment variable defined by a key and a value but with the possibility to define value validation rules.

func ParseEnvironmentVariable

func ParseEnvironmentVariable(variable string) (IEnvironmentVariable, error)

ParseEnvironmentVariable parses an environment variable definition, in the form "key=value".

Jump to

Keyboard shortcuts

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