Documentation
¶
Overview ¶
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
Index ¶
- type ASTNode
- type ExpressionMatch
- type ParsedArg
- type ParsedCommand
- type ParsedExpression
- type ParsedRedirect
- type ParsedRun
- type ParsedSubExpression
- type Parser
- func (p *Parser) GetCommentToken() string
- func (p *Parser) GetKind() model.FileKind
- func (p *Parser) Parse(ctx context.Context, fileContent []byte, filePath string, ...) (resolved []byte, documents []model.Document, ignoreLines []int, ...)
- func (p *Parser) StringifyContent(content []byte) (string, error)
- func (p *Parser) SupportedExtensions() []string
- func (p *Parser) SupportedTypes() map[string]bool
- type Span
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASTNode ¶
type ASTNode struct {
Type string `json:"type"` // Node type from tree-sitter
Value string `json:"value,omitempty"` // Text content
Children []ASTNode `json:"children,omitempty"` // Child nodes
}
ASTNode represents a simplified AST node
type ExpressionMatch ¶
type ExpressionMatch struct {
Full string `json:"full"` // Full match including ${{ }}
Expression string `json:"expression"` // Just the expression inside
FullSpan Span `json:"full_span"` // Span of full match
ExprSpan Span `json:"expr_span"` // Span of expression
}
ExpressionMatch represents a found expression in text
type ParsedArg ¶
type ParsedArg struct {
Type string `json:"type"` // "literal", "expansion", "command_substitution"
Value string `json:"value"` // The text content
Var string `json:"var,omitempty"` // Variable name if type is expansion
}
ParsedArg represents a command argument
type ParsedCommand ¶
type ParsedCommand struct {
Type string `json:"type"` // "command", "pipeline", "redirected_statement"
Command string `json:"command"` // Command name (e.g., "echo", "cargo")
Args []ParsedArg `json:"args"` // Command arguments
Redirect *ParsedRedirect `json:"redirect,omitempty"`
Pipeline []ParsedCommand `json:"pipeline,omitempty"`
}
ParsedCommand represents a parsed shell command
type ParsedExpression ¶
type ParsedExpression struct {
Raw string `json:"raw"` // Original expression text
AST ASTNode `json:"ast,omitempty"` // Parsed AST
ParseOK bool `json:"parse_ok"` // Whether parsing succeeded
Error error `json:"error,omitempty"` // Parse error if any
ConstantReducible bool `json:"constant_reducible"` // Can be evaluated at parse time
ConstantSubexprs []ParsedSubExpression `json:"constant_subexprs"` // Sub-expressions that are constant
ComputedIndices []ParsedSubExpression `json:"computed_indices"` // Dynamic array/object accesses
HasSecretsExpansion bool `json:"has_secrets_expansion"` // Uses toJSON(secrets) pattern
SecretsExpansionNodes []ParsedSubExpression `json:"secrets_expansion_nodes"` // Nodes with secrets expansion
HasDynamicSecretKey bool `json:"has_dynamic_secret_key"` // Uses secrets[variable]
DynamicSecretKeyNodes []ParsedSubExpression `json:"dynamic_secret_key_nodes"` // Nodes with dynamic secret access
}
ParsedExpression represents a parsed GitHub Actions expression
type ParsedRedirect ¶
type ParsedRedirect struct {
Operator string `json:"operator"` // ">>", ">", etc.
Target ParsedArg `json:"target"` // Redirect target
}
ParsedRedirect represents a file redirection
type ParsedRun ¶
type ParsedRun struct {
Shell string `json:"shell"` // "bash", "pwsh", etc.
Commands []ParsedCommand `json:"commands"` // All commands found
ParseOK bool `json:"parse_ok"` // Whether parsing succeeded
Error error `json:"error,omitempty"` // Parse error if any
}
ParsedRun represents a fully parsed run block
type ParsedSubExpression ¶
type ParsedSubExpression struct {
Type string `json:"type"` // Type of sub-expression
Value string `json:"value"` // Text value
}
ParsedSubExpression represents a sub-expression in the AST
type Parser ¶
type Parser struct{}
Parser defines a parser type
func (*Parser) GetCommentToken ¶
GetCommentToken return the comment token of YAML - #
func (*Parser) Parse ¶
func (p *Parser) Parse(ctx context.Context, fileContent []byte, filePath string, resolveReferences bool, maxResolverDepth int) ( resolved []byte, documents []model.Document, ignoreLines []int, resolvedFiles map[string]model.ResolvedFile, err error)
Parse parses yaml/yml file and returns it as a Document
func (*Parser) StringifyContent ¶
StringifyContent converts original content into string formatted version
func (*Parser) SupportedExtensions ¶
SupportedExtensions returns extensions supported by this parser, which are yaml and yml extension
func (*Parser) SupportedTypes ¶
SupportedTypes returns types supported by this parser, which are ansible, cloudFormation, k8s