Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) GetProjectFromPath(ctx context.Context, projectPath string) (Project, error)
- func (c *Client) GetRawFileFromProject(ctx context.Context, projectID int, fileName, ref string) ([]byte, error)
- func (c *Client) StreamAllProjects(ctx context.Context, pageSize int, projectsChan chan<- Project) error
- type HTTPDoer
- type ParseError
- type Project
- type RawFileError
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = errors.New("gitlan client is missing credentials to run, you need at least `read_api`")
var ErrNoRFC5988LinkHeader = errors.New("given string is not valid under RFC5988")
var ErrRawFileNotFound = errors.New("raw file was not found")
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client holds all authentication and setup information for the GitLab connection.
func NewClient ¶
NewClient sets up a client struct for all relevant GitLab auth you can give it a custom http.Client as well for things like timeouts.
func (*Client) GetProjectFromPath ¶ added in v0.13.2
func (*Client) GetRawFileFromProject ¶
func (c *Client) GetRawFileFromProject(ctx context.Context, projectID int, fileName, ref string) ([]byte, error)
GetRawFileFromProject wraps around the raw file endpoint of GitLab helping to fetch files from specific repos it will throw a typed ErrRawFileNotFound when it encounters a 404 response which you can errors.Is for to have cleaner logs.
func (*Client) StreamAllProjects ¶
func (c *Client) StreamAllProjects(ctx context.Context, pageSize int, projectsChan chan<- Project) error
StreamAllProjects iterates through all projects in a GitLab and streams them in batches of pageSize into the projectsChan. Due to this you want to buffer the projectsChan channel to something like 2 x pageSize depending on the speed and complexity of your consuming function. The authentication check retries for max 30s using an exponential backoff but will exit immediately if a 401 has been returned. All calls after this are not retried and a failing API call will stop the stream currently.
type ParseError ¶
func (*ParseError) Error ¶
func (pe *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (pe *ParseError) Unwrap() error
type Project ¶
type Project struct { ID int `json:"id"` DefaultBranch string `json:"default_branch"` PathWithNamespace string `json:"path_with_namespace"` }
Project is a minimalist representation of a GitLab project from https://docs.gitlab.com/ee/api/projects.html#get-single-project
type RawFileError ¶
func (*RawFileError) Error ¶
func (re *RawFileError) Error() string
func (*RawFileError) Unwrap ¶
func (re *RawFileError) Unwrap() error