import "github.com/egdaemon/eg/runtime/wasi/egenv"

func AccountID

func AccountID() string

Read the account ID from the environment

func Base64

func Base64(fallback []byte, keys ...string) []byte

Base64 read value as a base64 encoded string, the standard alphabet is attempted first and then the url alphabet.

func Base64URL

func Base64URL(fallback []byte, keys ...string) []byte

Base64URL read value as a url base64 encoded string

func Boolean

func Boolean(fallback bool, keys ...string) bool

Extract a boolean formatted environment variable from the given keys returns the first valid result if none of the keys exist then the fallback is returned.

func Build

func Build() *envx.Builder

func CacheDirectory

func CacheDirectory(paths ...string) string

returns the absolute path to the cache directory, when arguments are provided they are joined joined with the cache directory.

files stored in the cache directory are maintained between runs on a best effort basis. files prefixed with .eg are reserved for system use.

e.g.) CacheDirectory("foo", "bar") -> "/{eg.cache}/foo/bar"

func CloneEnabled

func CloneEnabled() bool

CloneEnabled reports whether the repository is cloned from, and so pushed to, a remote. false for `eg compute local`, which works on the local checkout where there is nothing to push to.

func Duration

func Duration(fallback time.Duration, keys ...string) time.Duration

Extract a time.Duration formatted environment variable from the given keys returns the first valid result if none of the keys exist then the fallback is returned.

func EphemeralDirectory

func EphemeralDirectory(paths ...string) string

returns the absolute path to the ephemeral directory, when arguments are provided they are joined joined with the ephemeral directory.

files stored in the ephemeral directory are maintained for the duration of a single module's execution. and is unique to that module.

e.g.) EphemeralDirectory("foo", "bar") -> "/{eg.ephemeral}/foo/bar"

func Initiated

func Initiated() time.Time

Initiated provides the instant the billed run duration started at. returns time.Now() as an approximation: when the runtime did not provide it, the time of the first call is used. the environment is only parsed once.

func Int

func Int(fallback int, keys ...string) int

Int retrieve a integer flag from the environment, checks each key in order first to parse successfully is returned.

func MustEnviron

func MustEnviron(env *envx.Builder) []string

func PathRelative

func PathRelative(dir string, path string) string

PathRelative reports paths within dir relative to it. relative paths and paths outside dir are returned as is.

func PathRelativeWorkspace

func PathRelativeWorkspace(path string) string

PathRelativeWorkspace reports paths within the workspace directory relative to it, so they hold wherever the workspace is located, e.g.) a git worktree. relative paths and paths outside the workspace are returned as is.

func RunID

func RunID() string

Read the run ID from the environment

func RuntimeDirectory

func RuntimeDirectory(paths ...string) string

returns the absolute path to the runtime directory, when arguments are provided they are joined joined with the runime directory.

files stored in the runtime directory are maintained for the duration of a workload. every module will be able to read the data stored in the runtime folder.

e.g.) RuntimeDirectory("foo", "bar") -> "/{eg.runtime}/foo/bar"

func String

func String(fallback string, keys ...string) string

Extract a string formatted environment variable from the given keys. returns the first valid result if none of the keys exist then the fallback is returned.

func TTL

func TTL() time.Duration

Provides the TTL specified by the runtime. used for setting context durations. defaults to an hour. currently not fully implemented.

func User

func User() *user.User

returns the current user.

func WorkingDirectory

func WorkingDirectory(paths ...string) string

returns the absolute path to the working directory of the module. this directory is the initial working directory of the workload and is used for cloning git repositories etc.

func Workload

func Workload() string

Read the entry path of the workload from the environment, empty when the runtime did not provide it.

func WorkloadDirectory

func WorkloadDirectory(paths ...string) string

returns the absolute path to the workload directory of the module. this directory is the root directory of the workload.

e.g.) WorkloadDirectory("foo", "bar") -> "/{eg.workload}/foo/bar"

func WorkloadName

func WorkloadName() string

Read the name of the workload (the module it runs, i.e. the folder name within the module directory) from the environment, empty for the default workload (see eg.DefaultWorkload).

func WorkspaceDirectory

func WorkspaceDirectory(paths ...string) string

returns the absolute path to the workspace directory, when arguments are provided they are joined joined with the workspace directory.

experimental directory - intended to be a directory for maintaining data for the lifetime of the workload.

e.g.) WorkspaceDirectory("foo", "bar") -> "/{eg.workspace}/foo/bar"

⬤