parser

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PARAMS_KEYS = []string{
	"when",
}

Keys that can have only a parameter inside it, and therefore the JSON Schema validation is not necessary for these keys.

Example:

`when: << parameters.my_param >>`

But in the JSON Schema, the `when` key is defined as an object, so the validation
will fail if we don't ignore it.

Functions

func AddOrbToCacheWithContent

func AddOrbToCacheWithContent(orb ast.Orb, uri protocol.URI, content []byte, context *utils.LsContext, cache *utils.Cache) error

func ExecQuery

func ExecQuery(node *sitter.Node, query string, fn func(match *sitter.QueryMatch)) error

func FindDeepestNode

func FindDeepestNode(rootNode *sitter.Node, content []byte, toFind []string) (*sitter.Node, error)

func GetBlockMappingNode

func GetBlockMappingNode(streamNode *sitter.Node) *sitter.Node

func GetChildMapping

func GetChildMapping(node *sitter.Node) *sitter.Node

func GetChildOfType

func GetChildOfType(node *sitter.Node, typeName string) *sitter.Node

func GetChildSequence

func GetChildSequence(node *sitter.Node) *sitter.Node

func GetFirstChild

func GetFirstChild(node *sitter.Node) *sitter.Node

func GetOrbInfo

func GetOrbInfo(orbVersionCode string, cache *utils.Cache, context *utils.LsContext) (*ast.OrbInfo, error)

func GetOrbParameters

func GetOrbParameters(orb *ast.OrbInfo, position protocol.Position) map[string]ast.Parameter

func GetOrbVersions

func GetOrbVersions(orbId string, token string, hostUrl, userId string) ([]struct{ Version string }, error)

func GetRootNode

func GetRootNode(content []byte) *sitter.Node

func GetVersionInfo

func GetVersionInfo(
	versions []struct{ Version string },
	initialVersion string,
) (string, string, string)

*

  • List all versions provided and return the latest minor, patch and major corresponding
  • to the current version. *
  • Notice: all versions number should have the format "v1.2.3" *
  • Return format: latest, latestMinor, latestMajor *
  • Where:
  • - latest: Latest version published
  • - latestMinor: Latest minor version published with the same major version
  • - latestPatch: Latest patch published with the same major.minor version

func ParseDockerImageValue

func ParseDockerImageValue(value string) ast.DockerImageInfo

func ParseRemoteOrbs

func ParseRemoteOrbs(orbs map[string]ast.Orb, cache *utils.Cache, context *utils.LsContext)

func ParseYamlAnchors

func ParseYamlAnchors(doc *YamlDocument) map[string]YamlAnchor

Types

type JSONSchemaValidator

type JSONSchemaValidator struct {
	Doc YamlDocument
	// contains filtered or unexported fields
}

func (*JSONSchemaValidator) LoadJsonSchema

func (validator *JSONSchemaValidator) LoadJsonSchema(schemaLocation string) error

func (*JSONSchemaValidator) ValidateWithJSONSchema

func (validator *JSONSchemaValidator) ValidateWithJSONSchema(rootNode *sitter.Node, content []byte) []protocol.Diagnostic

Validates a config YML against a JSON Shema Returns a list of diagnostics and a boolean that suggest whether to continue diagnostic or not

type LocalOrb

type LocalOrb struct {
	Name string
}

type ModifiedYamlDocument

type ModifiedYamlDocument struct {
	// The modified YAML Document
	Document YamlDocument

	// A short slug-like description of the way the document was modifier
	Tag string

	// Content added to the document
	Diff string
}

type OrbByNameResponse

type OrbByNameResponse struct {
	Orb OrbGQLData
}

type OrbGQLData

type OrbGQLData struct {
	ID   string
	Name string
}

func GetOrbByName

func GetOrbByName(orbName string, context *utils.LsContext) (OrbGQLData, error)

type OrbQuery

type OrbQuery struct {
	Id      string
	Version string
	Orb     struct {
		Id       string
		Versions []struct {
			Version string
		}
	}
	Source string
}

func GetRemoteOrb

func GetRemoteOrb(orbId string, token string, hostUrl, userId string) (OrbQuery, error)

type OrbResponse

type OrbResponse struct {
	OrbVersion OrbQuery
}

type YamlAnchor

type YamlAnchor struct {
	Name            string
	DefinitionRange protocol.Range
	References      *[]protocol.Range
	ValueNode       *sitter.Node
}

type YamlDocument

type YamlDocument struct {
	Content        []byte
	RootNode       *sitter.Node
	Version        float32
	Description    string
	URI            protocol.URI
	Diagnostics    *[]protocol.Diagnostic
	Context        *utils.LsContext
	SchemaLocation string

	Orbs               map[string]ast.Orb
	LocalOrbs          []LocalOrb
	Executors          map[string]ast.Executor
	Commands           map[string]ast.Command
	Jobs               map[string]ast.Job
	Workflows          map[string]ast.Workflow
	PipelineParameters map[string]ast.Parameter
	YamlAnchors        map[string]YamlAnchor

	OrbsRange               protocol.Range
	ExecutorsRange          protocol.Range
	CommandsRange           protocol.Range
	JobsRange               protocol.Range
	WorkflowRange           protocol.Range
	PipelineParametersRange protocol.Range
	VersionRange            protocol.Range

	LocalOrbInfo map[string]*ast.OrbInfo

	LocalOrbName string
	Offset       protocol.Position
}

func ParseFile

func ParseFile(content []byte, context *utils.LsContext) YamlDocument

func ParseFromContent

func ParseFromContent(content []byte, context *utils.LsContext, URI protocol.URI, offset protocol.Position) (YamlDocument, error)

func ParseFromURI

func ParseFromURI(URI protocol.URI, context *utils.LsContext) (YamlDocument, error)

func ParseFromUriWithCache

func ParseFromUriWithCache(URI protocol.URI, cache *utils.Cache, context *utils.LsContext) (YamlDocument, error)

func (*YamlDocument) CouldBeOrbReference

func (doc *YamlDocument) CouldBeOrbReference(orbReference string) (string, bool)

func (*YamlDocument) DoesCommandExist

func (doc *YamlDocument) DoesCommandExist(commandName string) bool

func (*YamlDocument) DoesCommandOrJobOrExecutorExist

func (doc *YamlDocument) DoesCommandOrJobOrExecutorExist(name string, includeCommands bool) bool

func (*YamlDocument) DoesExecutorExist

func (doc *YamlDocument) DoesExecutorExist(executorName string) bool

func (*YamlDocument) DoesJobExist

func (doc *YamlDocument) DoesJobExist(jobName string) bool

func (*YamlDocument) DoesOrbExist

func (doc *YamlDocument) DoesOrbExist(orb ast.Orb, cache *utils.Cache) bool

func (*YamlDocument) DoesWorkflowExist

func (doc *YamlDocument) DoesWorkflowExist(workflowName string) bool

func (*YamlDocument) FromOrbParsedAttributesToYamlDocument

func (doc *YamlDocument) FromOrbParsedAttributesToYamlDocument(orb ast.OrbParsedAttributes) YamlDocument

func (*YamlDocument) GetDefinedParams

func (doc *YamlDocument) GetDefinedParams(entityName string, cache *utils.Cache) map[string]ast.Parameter

func (*YamlDocument) GetExecutorDefinedAtPosition

func (doc *YamlDocument) GetExecutorDefinedAtPosition(position protocol.Position) ast.Executor

func (*YamlDocument) GetKeyValueNodes

func (doc *YamlDocument) GetKeyValueNodes(node *sitter.Node) (keyNode *sitter.Node, valueNode *sitter.Node)

func (*YamlDocument) GetNodeText

func (doc *YamlDocument) GetNodeText(node *sitter.Node) string

func (*YamlDocument) GetNodeTextWithRange

func (doc *YamlDocument) GetNodeTextWithRange(node *sitter.Node) ast.TextAndRange

func (*YamlDocument) GetOrFetchOrbInfo

func (doc *YamlDocument) GetOrFetchOrbInfo(orb ast.Orb, cache *utils.Cache) (*ast.OrbInfo, error)

func (*YamlDocument) GetOrbDefinedParams

func (doc *YamlDocument) GetOrbDefinedParams(entityName string, cache *utils.Cache) map[string]ast.Parameter

func (*YamlDocument) GetOrbInfoFromName

func (doc *YamlDocument) GetOrbInfoFromName(name string, cache *utils.Cache) (*ast.OrbInfo, error)

func (*YamlDocument) GetOrbURLDefinition

func (doc *YamlDocument) GetOrbURLDefinition(node *sitter.Node) ast.OrbURLDefinition

func (*YamlDocument) GetParameterType

func (doc *YamlDocument) GetParameterType(paramNode *sitter.Node) (paramType string, paramTypeRange protocol.Range)

func (*YamlDocument) GetParamsWithPosition

func (doc *YamlDocument) GetParamsWithPosition(position protocol.Position) map[string]ast.Parameter

func (*YamlDocument) GetRawNodeText

func (doc *YamlDocument) GetRawNodeText(node *sitter.Node) string

func (*YamlDocument) GetWorkflows

func (doc *YamlDocument) GetWorkflows() []ast.TextAndRange

func (*YamlDocument) GetYamlAnchorAtPosition

func (doc *YamlDocument) GetYamlAnchorAtPosition(pos protocol.Position) (YamlAnchor, bool)

func (*YamlDocument) InsertText

func (doc *YamlDocument) InsertText(pos protocol.Position, text string) (YamlDocument, error)

func (*YamlDocument) IsAlias

func (doc *YamlDocument) IsAlias(commandName string) bool

func (*YamlDocument) IsBuiltIn

func (doc *YamlDocument) IsBuiltIn(commandName string) bool

func (*YamlDocument) IsFromUnfetchableOrb

func (doc *YamlDocument) IsFromUnfetchableOrb(name string) bool

Takes the name of anything that may be in an orb and returns if it is inside an orb that we can not use

func (*YamlDocument) IsGivenOrb

func (doc *YamlDocument) IsGivenOrb(commandName string, orbName string) bool

func (*YamlDocument) IsOrbCommand

func (doc *YamlDocument) IsOrbCommand(orbCommand string, cache *utils.Cache) bool

func (*YamlDocument) IsOrbJob

func (doc *YamlDocument) IsOrbJob(orbCommand string, cache *utils.Cache) bool

func (*YamlDocument) IsOrbReference

func (doc *YamlDocument) IsOrbReference(orbReference string) bool

func (*YamlDocument) IsSelfHostedRunner

func (doc *YamlDocument) IsSelfHostedRunner(resourceClass string) bool

func (*YamlDocument) IsYamlAliasPosition

func (doc *YamlDocument) IsYamlAliasPosition(pos protocol.Position) bool

func (*YamlDocument) ModifyTextForAutocomplete

func (doc *YamlDocument) ModifyTextForAutocomplete(pos protocol.Position) []ModifiedYamlDocument

func (*YamlDocument) NodeToRange

func (doc *YamlDocument) NodeToRange(node *sitter.Node) protocol.Range

func (*YamlDocument) ParseYAML

func (doc *YamlDocument) ParseYAML(context *utils.LsContext, offset protocol.Position)

func (*YamlDocument) ToOrbParsedAttributes

func (doc *YamlDocument) ToOrbParsedAttributes() ast.OrbParsedAttributes

func (*YamlDocument) ValidateYAML

func (doc *YamlDocument) ValidateYAML()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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