environment

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package environment provides basic environment definitions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Supports

func Supports(env Environment, components ...interface{}) ([]interface{}, bool)

Supports returns a list of components that support the given environment, and a boolean indicating if all components support the environment

func Variable

func Variable(name, defaultValue string) string

Variable returns the value of an environment variable, or a default value if not set

Types

type Environment

type Environment string

Environment is a type that represents an environment name

const Development Environment = "development"

Development Development Environments

const IntegrationTest Environment = "integrationtest"

IntegrationTest - distributed testing, combining multiple repos & external services

const Local Environment = "local"

Local Local Development Environments

const Production Environment = "production"

Production live environment

const Sandbox Environment = "sandbox"

Sandbox public test environment

const UnitTest Environment = "unittest"

UnitTest Test Environments - same repo testing

func Parse

func Parse(input string) (Environment, error)

Parse parses a string into an environment

func (Environment) AllowTestData

func (e Environment) AllowTestData() bool

AllowTestData Check to allow for test data per environment

func (Environment) GetIdentifier

func (e Environment) GetIdentifier() string

GetIdentifier returns the identifier for the environment, this is a single character for known environments, and 2 characters for unknown environments

func (Environment) IsDevOrTest

func (e Environment) IsDevOrTest() bool

IsDevOrTest returns true if the environment is development, local, or a test case

func (Environment) IsDevelopment

func (e Environment) IsDevelopment() bool

IsDevelopment returns true if the environment is development

func (Environment) IsIntegrationTest

func (e Environment) IsIntegrationTest() bool

IsIntegrationTest returns true if the environment is an integration test

func (Environment) IsLocal

func (e Environment) IsLocal() bool

IsLocal returns true if the environment is local

func (Environment) IsProduction

func (e Environment) IsProduction() bool

IsProduction returns true if the environment is production

func (Environment) IsSandbox

func (e Environment) IsSandbox() bool

IsSandbox returns true if the environment is a sandbox

func (Environment) IsTestCase

func (e Environment) IsTestCase() bool

IsTestCase returns true if the environment is a test case either unit or integration

func (Environment) IsUnitTest

func (e Environment) IsUnitTest() bool

IsUnitTest returns true if the environment is a unit test

type Name

type Name string

Name is a type that represents an environment variable name

func (Name) String

func (v Name) String() string

Returns the string representation of the Name

func (Name) Value

func (v Name) Value() string

Value returns the value of the environment variable, or an empty string if not set

func (Name) ValueInt

func (v Name) ValueInt() (int, error)

ValueInt returns the value of the environment variable as an integer, or an error if not set

func (Name) ValueOrPanic

func (v Name) ValueOrPanic() string

ValueOrPanic returns the value of the environment variable, or panics if not set

func (Name) WithDefault

func (v Name) WithDefault(defaultValue string) string

WithDefault returns the value of the environment variable, or a default value if not set

type Supporter

type Supporter interface {
	SupportsEnvironment(environment Environment) bool
}

Supporter is an interface that can be implemented by any component to identify if it supports a given environment

Jump to

Keyboard shortcuts

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