Documentation ¶
Overview ¶
Package glen provides an API to get GitLab project and group variables
Glen has a VERY simple API with two structs that combined can get GitLab environment variables from a local repo with a GitLab remote.
Repo ¶
The Repo struct holds information about a local repo and can be passed to a Variables struct. By default Repo assumes that your current working directory has a remote named 'origin'. However, you can specify custom directtories and custom origin names.
Variables ¶
The Variables struct holds information about a GitLab project's CI/CD variables. By default Variables collects a project's variables using your GITLAB_TOKEN environment variable API key. However, you can set a custom API key and you can set Variables.Recurse=true to also collect the group variables of the project's parent groups. Variables are merged according to the GitLab specified precedence here: https://docs.gitlab.com/ee/ci/variables/#priority-of-environment-variables
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct { LocalPath string RemoteName string Path string BaseURL string HTTPURL string RemoteURL string Groups []string }
Repo represents information about a git repo. Repo does not represent ALL information about a repo, only the information needed for this package (for gathering GitLab variables).
func NewRepo ¶
func NewRepo() *Repo
NewRepo creates a new repo struct with defaults that assume you have a remote named 'origin' and that you are calling this function while your current directory is the repo you're interested in. If you have a custom local path or your remote is not named 'origin' then make sure you set those before you Init() the repo.
type Variables ¶
type Variables struct { Env map[string]string GroupOnly bool Recurse bool Repo *Repo // contains filtered or unexported fields }
Variables represents a set of CI/CD environment variables and the repo that those variables were collected from.
func NewVariables ¶
NewVariables takes a *Repo and returns an empty Variables struct. This assumes that you have a GitLab API key set as GITLAB_TOKEN. If not, make sure you set one with Variables.SetAPIKey(). Note that by default we do not 'recurse' and get the group variables. If you want group variables merged in make sure you set Variables.Recurse=true.
func (*Variables) Init ¶
Init collects GitLab variables from the repo, and optionally from the parent groups if Variables.Recurse=true. Variable precedence respects https://docs.gitlab.com/ee/ci/variables/#priority-of-environment-variables
func (*Variables) IsAPIKeySet ¶ added in v1.8.0
IsAPIKeySet checks if apiKey is set to a non-empty value.