ci_yaml

package
v0.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResult = errors.New("no remote url could validate due to invalid responses")

ErrNoResult happens when no remote can validate the CI as the requests don't succeed

View Source
var ErrTimeout = errors.New("no remote url could validate due to a timeout")

ErrTimeout happens when no remote can validate the CI linting after the specified timeout

Functions

func ExtractScripts added in v0.0.2

func ExtractScripts(doc *yaml.Node) chan JobWithScripts

ExtractScripts from a YAML document

Types

type JobWithScripts added in v0.0.2

type JobWithScripts struct {
	// JobName contains the name of the job the scripts are part of
	JobName string
	// ScriptParts contains the script parts indexed by the key of the job
	ScriptParts map[string][]ScriptPart
}

JobWithScripts represents the parsed scripts from a job and the name of the job

type ScriptPart added in v0.0.2

type ScriptPart struct {
	// Content is the script content lines
	Content string
	// Node the script was extracted from
	Node *yaml.Node
}

ScriptPart represents a part of a script

func (*ScriptPart) SplitContentLines added in v0.0.2

func (s *ScriptPart) SplitContentLines() []ScriptPartLine

SplitContentLines from a part

type ScriptPartLine added in v0.0.2

type ScriptPartLine struct {
	// LineContent is a line of a script part
	LineContent string
	// LineNumber contains the number in which the line was found
	LineNumber int
	// Node the script was extracted from
	Node *yaml.Node
}

ScriptPartLine represents a line of a script part

func Concat added in v0.0.2

func Concat(parts []ScriptPart) ([]ScriptPartLine, []byte)

Concat all given ScriptPart's into one string and return the lines as well as the buffer

type VerificationResultWithRemoteInfo

type VerificationResultWithRemoteInfo struct {
	RemoteInfo *git.GitlabRemoteUrlInfo
	LintResult *api.CiLintResult
}

VerificationResultWithRemoteInfo contains both the remote that was used and the according lint result

func GetFirstValidationResult

func GetFirstValidationResult(remoteInfos []git.GitlabRemoteUrlInfo, token string, baseUrlOverwrite string, ciYaml []byte, timeout time.Duration) (*VerificationResultWithRemoteInfo, error)

GetFirstValidationResult starts a parallel request to all remotes and tries to use the API to lint the CI file the first to report a result will be used as a validation result. If none of the remotes can produce a result or timeout is reached, the validation is aborted and the error is set accordingly.

Jump to

Keyboard shortcuts

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