Documentation
¶
Overview ¶
Package gitlabclient provides utilities for creating and configuring a GitLab API client. It retrieves the GitLab personal access token from the environment variable `GITLAB_API_KEY` and determines the GitLab BaseURL from either the provided input or environment variables. If no BaseURL is specified, it defaults to `https://gitlab.com/`.
Typical usage:
client, err := gitlabclient.LoadClient(input)
if err != nil {
// handle error
}
The package relies on:
- github.com/simon-fredrich/function-gitlab-importer/input/v1beta1 for input structure
- gitlab.com/gitlab-org/api/client-go for GitLab API interactions
- github.com/crossplane/function-sdk-go/errors for error handling
This package is intended for use in a Crossplane Composition Function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadClient ¶
LoadClient initializes and returns a GitLab API client for use in Crossplane functions. It retrieves the GitLab personal access token from the environment variable `GITLAB_API_KEY`. If the token is missing, an error is returned.
The GitLab BaseURL is resolved in the following order:
- From the provided Crossplane function input (`in.BaseURL`).
- From the environment variable `GITLAB_URL`.
- Defaults to `https://gitlab.com/` if neither is provided.
The function then creates a new GitLab client using the token and the resolved BaseURL, appending `/api/v4` to the URL.
Returns:
- A configured *gitlab.Client instance if successful.
- An error if the token is missing or the client cannot be created.
This helper is designed for Crossplane function implementations that need to interact with the GitLab API in a dynamic and configurable way.
Types ¶
This section is empty.