Documentation ¶
Index ¶
- Variables
- func ParsePipelineMessage(message string) (string, string)
- type CiLintResult
- type Client
- func (g *Client) Do(r *Request) (*Response, error)
- func (g *Client) LintCiYaml(ctx context.Context, projectSlug string, ciYaml []byte) (*CiLintResult, error)
- func (g *Client) NewRequest(method string, path string, payload []byte) (*Request, error)
- func (g *Client) NewRequestWithContext(ctx context.Context, method string, path string, payload []byte) (*Request, error)
- type EnvVarTokenSource
- type NetRcTokenSource
- type Request
- type Response
- type TokenSource
- type TokenSourceLookupHints
- type VaultTokenSource
Constants ¶
This section is empty.
Variables ¶
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
var ErrInvalidAuthentication = errors.New("got HTTP/401 when trying to call lint API, verify your credentials are valid")
ErrInvalidAuthentication indicates the authentication is invalid
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
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 NewClientWithMultiTokenSources ¶
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) LintCiYaml ¶
func (g *Client) LintCiYaml(ctx context.Context, projectSlug string, ciYaml []byte) (*CiLintResult, error)
LintCiYaml against the api for a project
func (*Client) NewRequest ¶
NewRequest creates a new request prefixing it with the base url and adding the GitLab access token
type EnvVarTokenSource ¶ added in v0.4.0
type EnvVarTokenSource struct{}
func (EnvVarTokenSource) Lookup ¶ added in v0.4.0
func (e EnvVarTokenSource) Lookup(_ TokenSourceLookupHints) (string, error)
type NetRcTokenSource ¶ added in v0.4.0
type NetRcTokenSource struct{}
func (NetRcTokenSource) Lookup ¶ added in v0.4.0
func (n NetRcTokenSource) Lookup(t TokenSourceLookupHints) (string, error)
type Request ¶
Request wraps a regular http.Request to make it more explicit for the gitlab api client
type Response ¶
Response as returned by gitlab api client methods
func (*Response) CheckStatus ¶
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 ¶
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 VaultTokenSource ¶ added in v0.4.0
type VaultTokenSource struct{}
func (VaultTokenSource) Lookup ¶ added in v0.4.0
func (v VaultTokenSource) Lookup(t TokenSourceLookupHints) (string, error)