gitlabapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const GitlabApiVersion = "v4"

Variables

This section is empty.

Functions

func EscapeBashCharacters

func EscapeBashCharacters(s string) string

function EscapeBashCharacters espace bash characters

func ExpandAndPrintVars

func ExpandAndPrintVars(vars Variables)

ExpandAndPrintVars expands the variables and prints them to stdout

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv replaces ${var} or $var in the string based on the values of the current environment variables. The replacement is case-sensitive. References to undefined variables are replaced by the empty string. A default value can be given by using the form ${var:-default value}. The default value is used only if var is unset or empty. A different value can be given by using the form ${var:default value}. The default value is used if var is unset. References to other variables are expanded as the string is processed. Recursive references are not allowed. If there is an error in the syntax of the variable reference, the reference is replaced by the empty string.

func FindProject

func FindProject(remoteOrigin string) (*project, error)

func GetAllGroupParentId

func GetAllGroupParentId(groupId int) ([]int, error)

func GetIndexOfVar

func GetIndexOfVar(vars []Variable, key string) int

GetIndexOfVar returns the index of a variable in a list of variables

func IsVarPartOfScope

func IsVarPartOfScope(environment string, varScope string) bool

IsVarPartOfScope is checking if the environment is part of the scope for example if the environment is "staging" and the scope is "staging" it returns true if the environment is "staging" and the scope is "staging*" it returns true if the environment is "staging/mtrg" and the scope is "staging*" it returns true if the environment is "staging/mtrg" and the scope is "production" it returns false

func IsVarPresent

func IsVarPresent(vars []Variable, key string) bool

IsVarPresent checks if a variable is present in a list of variables

Types

type GitlabApiClient

type GitlabApiClient struct {
	HttpClient HTTPClient
}

func NewGitlapApiClient

func NewGitlapApiClient() *GitlabApiClient

func (*GitlabApiClient) Request

func (g *GitlabApiClient) Request(uri string) (body []byte, err error)

type GitlabGroup

type GitlabGroup struct {
	Id       int    `json:"id"`
	Name     string `json:"name"`
	ParentId int    `json:"parent_id"`
}

func GetGroup

func GetGroup(groupId int) (*GitlabGroup, error)

func (*GitlabGroup) GetAllGroupParentId

func (g *GitlabGroup) GetAllGroupParentId() ([]int, error)

func (*GitlabGroup) GetAllVars

func (g *GitlabGroup) GetAllVars(scope string) ([]Variable, error)

func (*GitlabGroup) GetParentId

func (g *GitlabGroup) GetParentId() int

func (*GitlabGroup) GetVarsOfGroup

func (g *GitlabGroup) GetVarsOfGroup(scope string) (Variables, error)

func (*GitlabGroup) IsRootGroup

func (g *GitlabGroup) IsRootGroup() bool

type GitlabNamespace

type GitlabNamespace struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type GitlabProject

type GitlabProject struct {
	Id        int             `json:"id"`
	Namespace GitlabNamespace `json:"namespace"`
}

func GetProject

func GetProject(projectId int) (*GitlabProject, error)

func (*GitlabProject) GetAllVars

func (p *GitlabProject) GetAllVars(scope string) ([]Variable, error)

func (*GitlabProject) GetGroupId

func (r *GitlabProject) GetGroupId() int

func (*GitlabProject) GetVarsOfProject

func (p *GitlabProject) GetVarsOfProject(scope string) (Variables, error)

func (*GitlabProject) IsRootGroup

func (r *GitlabProject) IsRootGroup() bool

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Variable

type Variable struct {
	VariableType     string `json:"variable_type"`
	Key              string `json:"key"`
	Value            string `json:"value"`
	Protected        bool   `json:"protected"`
	Masked           bool   `json:"masked"`
	Raw              bool   `json:"raw"`
	EnvironmentScope string `json:"environment_scope"`
}

func MergeVars

func MergeVars(parentVars []Variable, childVars []Variable) []Variable

MergeVars merges two lists of variables if a variable is present in both lists, the variable from the child list is used

func RemoveVar

func RemoveVar(vars []Variable, idx int) (res []Variable)

RemoveVar removes a variable from a list of variables

type Variables

type Variables []Variable

func FilterVars

func FilterVars(vars Variables, scope string) Variables

FilterVars filters the variables based on the scope

func (Variables) GetVarOfScope

func (v Variables) GetVarOfScope(key string, scope string) (Variable, error)

GetVarOfScope returns the variable of a scope

func (Variables) GetVarValue

func (v Variables) GetVarValue(key string) (string, error)

GetVarValue returns the value of a variable

Jump to

Keyboard shortcuts

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