api

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = errors.New("got HTTP/403 when trying to call lint API, make sure you have access to the lint API for the project")

ErrForbidden indicates that the authentication is valid, but the requesting user does not have permission

View Source
var ErrInvalidAuthentication = errors.New("got HTTP/401 when trying to call lint API, verify your credentials are valid")

ErrInvalidAuthentication indicates the authentication is invalid

View Source
var ErrNotFound = errors.New("got HTTP/404 when trying to call lint API, verify at least one remote is using GitLab")

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. The Token specified via parameter is non-empty 2. Try to look up tokenSources and use the first one without an error and return a non-empty string

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 EnvVarTokenSource added in v0.4.0

type EnvVarTokenSource struct{}

func (EnvVarTokenSource) Lookup added in v0.4.0

type NetRcTokenSource added in v0.4.0

type NetRcTokenSource struct{}

func (NetRcTokenSource) Lookup added in v0.4.0

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

type TokenSource added in v0.4.0

type TokenSource interface {
	Lookup(baseUrl TokenSourceLookupHints) (string, error)
}

type TokenSourceLookupHints added in v0.4.0

type TokenSourceLookupHints struct {
	ExistingToken string
	BaseUrl       string
}

type VaultTokenSource added in v0.4.0

type VaultTokenSource struct{}

func (VaultTokenSource) Lookup added in v0.4.0

Jump to

Keyboard shortcuts

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