env

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// TagBuild indicates release build
	TagBuild = BuildVar("RELEASE_BUILD")

	// RCBuild indicates a release candidate build (containing "-rc")
	RCBuild = BuildVar("RC_BUILD")

	// SnapshotBuild indicates snapshot release build (master branch)
	SnapshotBuild = BuildVar("SNAPSHOT_BUILD")

	// PRBuild indicates pull-request build
	PRBuild = BuildVar("PR_BUILD")

	// BuildVersion stores build version
	BuildVersion = BuildVar("BUILD_VERSION")

	// PPAVersion stores build version for PPA
	PPAVersion = BuildVar("PPA_VERSION")

	// BuildNumber stores CI build number
	BuildNumber = BuildVar("BUILD_NUMBER")

	// BuildTag stores git tag for build
	BuildTag = BuildVar("BUILD_TAG")

	// BuildBranch stores branch name
	BuildBranch = BuildVar("BUILD_BRANCH")

	// BuildCommit stores git commit short SHA
	BuildCommit = BuildVar("BUILD_COMMIT")

	// BuildBranchSafe stores branch name, with special characters replaced with hyphens
	BuildBranchSafe = BuildVar("BUILD_BRANCH_SAFE")

	// GithubOwner stores github repository's owner
	GithubOwner = BuildVar("GITHUB_OWNER")

	// GithubRepository stores github repository name
	GithubRepository = BuildVar("GITHUB_REPO")

	// GithubSnapshotRepository stores github repository name for snapshot builds
	GithubSnapshotRepository = BuildVar("GITHUB_SNAPSHOT_REPO")

	// GithubAPIToken is used for accessing github API
	GithubAPIToken = BuildVar("GITHUB_API_TOKEN")

	// DockerHubUsername is hub.docker.com username under which to push snapshot builds
	DockerHubUsername = BuildVar("DOCKERHUB_USERNAME")

	// DockerHubPassword is hub.docker.com password of DockerHubUsername
	DockerHubPassword = BuildVar("DOCKERHUB_PASSWORD")

	// CommitMessage is HEAD commit message
	CommitMessage = BuildVar("CI_COMMIT_MESSAGE")
)

Variables

This section is empty.

Functions

func Bool

func Bool(v BuildVar) bool

Bool reads a bool env var. EnsureEnvVars should be called first to ensure it has a specified value.

func EnsureEnvVars

func EnsureEnvVars(vars ...BuildVar) error

EnsureEnvVars ensures that specified environment variables have a value. Purpose is to reduce boilerplate in mage target when reading multiple env vars.

func GenerateEnvFile

func GenerateEnvFile() error

GenerateEnvFile for sourcing in other stages

func IfRelease

func IfRelease(do func() error) error

IfRelease performs func passed as an arg if current build is any kind of release

func IsFullBuild

func IsFullBuild() (bool, error)

IsFullBuild true when full build is requested via commit message `[ci full]`

func IsPR

func IsPR() (bool, error)

IsPR true when building a Pull Request.

func IsRelease

func IsRelease() (bool, error)

IsRelease true when building a release (tag or snapshot).

func Str

func Str(v BuildVar) string

Str reads a string env var. EnsureEnvVars should be called first to ensure it has a specified value.

func WriteEnvVars

func WriteEnvVars(vars []EnvVar, filename string) error

WriteEnvVars writes vars to a shell script so they can be sourced `source env.sh` in latter build stages

Types

type BuildVar

type BuildVar string

BuildVar env variables used in CI build. Some of them will be calculated when generating env file, others should be passed though env.

type EnvVar

type EnvVar struct {
	Key BuildVar
	Val string
}

EnvVar represents an environment variable's value.

Jump to

Keyboard shortcuts

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