environment

package
v0.12.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package environment provides utility functions for accessing and managing environment variables.

It is generally not called as part of the API, and like the global package is mainly used for utility within the rest of the go-credentials library.

Index

Constants

View Source
const ERR_CANT_LOAD_WITH_EMPTY_VALUES = "sorry values required for application name and username, cannot deploy"
View Source
const ERR_KEY_MUST_MATCH_REGEX = "sorry the key must only include letters and underscores [0-9A-Za-z_]"
View Source
const ERR_REQUIRED_VARIABLE_PASSWORD_NOT_FOUND = "password has not been set via the environment and is required, load failed"
View Source
const ERR_REQUIRED_VARIABLE_USERNAME_NOT_FOUND = "username has not been set via the environment and is required, load failed"

Variables

This section is empty.

Functions

func CleanEnvironment

func CleanEnvironment(variables []string) error

CleanEnvironment deletes each environment variable in the variables array.

func Deploy

func Deploy(applicationName string, username string, password string, alternates map[string]string, attributes map[string]map[string]string) ([]string, error)

Deploy is responsible for setting environment variables based on the values passed in. If no alternates are set, the username and password will be set as APP_NAME_USERNAME and APP_NAME_PASSWORD respectively. If alternates are set, the key values will be replaced with those names instead. All attributes will then be set in the format of APP_NAME_ATTRIBUTE_NAME. The names of each environment variable are returned as a string array. This is to allow for cleanup of the environment variables if you want them deleted.

func Load

func Load(applicationName string, alternates map[string]string) (map[string]string, error)

Load is responsible for scanning environment variables and retrieves applicable variables that have the prefix of applicationName. When it finds an environment variable with this prefix, it will note the key (sans prefix) and the value. The resulting map that is returned is combination of the cleansed key and the value that was set. This map can be empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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