GitHubActions.Config (GitHubActions v0.1.1) View Source

A simple keyword-based configuration API.

Examples

This module is used to define the configuration for GitHubActions.

import GitHubActions.Config

config :linux,
  name: "Ubuntu",
  runs_on: "ubuntu-latest"

config key: "value"

Link to this section Summary

Functions

Returns the configuaration.

Adds the given data to the configuration.

Adds the given value to the configuration under the given key.

Returns the value for key or keys in a tuple.

Returns the value for key or keys.

Returns the value for key or keys.

Reads the configuration from the given path.

Link to this section Types

Specs

config() :: keyword()

Specs

key() :: atom()

Specs

keys() :: [atom()]

Specs

value() :: any()

Link to this section Functions

Specs

config() :: config()

Returns the configuaration.

Specs

config(config()) :: config() | nil

Adds the given data to the configuration.

Returns the configuration that was previously stored.

Specs

config(key(), value()) :: config() | nil

Adds the given value to the configuration under the given key.

Returns the configuration that was previously stored.

Specs

fetch(key() | keys()) :: value()

Returns the value for key or keys in a tuple.

If the configuration parameter does not exist, the function returns error.

Examples

iex> Config.fetch(:jobs)
{:ok, [:linux]}

iex> Config.fetch(:foo)
:error

iex> Config.fetch([:linux, :name])
{:ok, "Ubuntu"}

Returns the value for key or keys.

Examples

iex> Config.fetch!(:jobs)
[:linux]

iex> Config.fetch!([:linux, :runs_on])
"ubuntu-latest"

iex> Config.fetch!([:linux, :foo])
** (KeyError) key :foo not found in: [name: "Ubuntu", runs_on: "ubuntu-latest"]
Link to this function

get(keys, default \\ nil)

View Source

Specs

get(key() | keys(), value()) :: value()

Returns the value for key or keys.

If the configuration parameter does not exist, the function returns the default value.

Examples

iex> Config.get(:jobs)
[:linux]

iex> Config.get(:foo, :bar)
:bar

iex> Config.get([:linux, :runs_on])
"ubuntu-latest"

iex> Config.get(:foo)
nil

Specs

read(Path.t()) :: :ok | {:error, :enonet}

Reads the configuration from the given path.