api

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAuthentication = errors.New("invalid authentication")

ErrInvalidAuthentication indicates the authentication is invalid

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound indicates the resource or route does not exist

Functions

func ParsePipelineMessage added in v0.0.2

func ParsePipelineMessage(message string) (string, string)

ParsePipelineMessage from gitlab api for a message and return the job and the message

Types

type CiLintResult

type CiLintResult struct {
	// Valid indicates if the YAML file is syntactically correct
	Valid bool `json:"valid"`
	// MergedYaml contains the final YAML with all includes and anchors resolved
	MergedYaml string `json:"mergedYaml"`
	// Errors encountered with the pipeline
	Errors []string `json:"errors"`
	// Warnings encountered with the pipeline
	Warnings []string `json:"warnings"`
}

CiLintResult represents the response from the Gitlab API when a YAML file has been validated

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client to access the gitlab api

func NewClient

func NewClient(baseUrl string, token string) *Client

NewClient creates a new api client instance for the gitlab api

func NewClientWithMultiTokenSources

func NewClientWithMultiTokenSources(baseUrl string, token string) *Client

NewClientWithMultiTokenSources creates a new client instance for the gitlab api, taking multiple sources for the token The order is as following 1. token specified via parameter is non-empty 2. netrc contains a host entry with a password 3. environment variable GITLAB_TOKEN is set

func (*Client) Do

func (g *Client) Do(r *Request) (*Response, error)

Do the http request to the gitlab api

func (*Client) LintCiYaml

func (g *Client) LintCiYaml(ctx context.Context, projectSlug string, ciYaml []byte) (*CiLintResult, error)

LintCiYaml against the api for a project

func (*Client) NewRequest

func (g *Client) NewRequest(method string, path string, payload []byte) (*Request, error)

NewRequest creates a new request prefixing it with the base url and adding the GitLab access token

func (*Client) NewRequestWithContext

func (g *Client) NewRequestWithContext(ctx context.Context, method string, path string, payload []byte) (*Request, error)

NewRequestWithContext creates a new request prefixing it with the base url and adding the GitLab access token bound to a context

type Request

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

Request wraps a regular http.Request to make it more explicit for the gitlab api client

func NewRequest

func NewRequest(ctx context.Context, method string, baseUrl string, path string, token string, payload []byte) (*Request, error)

NewRequest for usage with gitlab api client

type Response

type Response struct {
	*http.Response
}

Response as returned by gitlab api client methods

func (*Response) CheckStatus

func (r *Response) CheckStatus() error

CheckStatus for the response for common errors and return, according errors, if the HTTP status code does not indicate a general error nil is returned.

func (*Response) UnmarshalJson

func (r *Response) UnmarshalJson(val interface{}) error

UnmarshalJson from the response

Jump to

Keyboard shortcuts

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