schema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFunction

func AddFunction(funcs *[]FunctionInfo, s string, i1, i2 int)

Types

type BasicFunctionInfo added in v0.4.0

type BasicFunctionInfo struct {
	Name string
	Min  int
	Max  int
}

func (BasicFunctionInfo) Check added in v0.4.0

func (f BasicFunctionInfo) Check(args []exprparser.Node) error

func (BasicFunctionInfo) GetName added in v0.4.0

func (f BasicFunctionInfo) GetName() string

type BooleanDefinition

type BooleanDefinition struct {
}

type Definition

type Definition struct {
	Context       []string            `json:"context,omitempty"`
	Mapping       *MappingDefinition  `json:"mapping,omitempty"`
	Sequence      *SequenceDefinition `json:"sequence,omitempty"`
	OneOf         *[]string           `json:"one-of,omitempty"`
	AllowedValues *[]string           `json:"allowed-values,omitempty"`
	String        *StringDefinition   `json:"string,omitempty"`
	Number        *NumberDefinition   `json:"number,omitempty"`
	Boolean       *BooleanDefinition  `json:"boolean,omitempty"`
	Null          *NullDefinition     `json:"null,omitempty"`
}

type FunctionInfo

type FunctionInfo interface {
	GetName() string
	Check(args []exprparser.Node) error
}

type Location added in v0.4.0

type Location struct {
	Line   int
	Column int
}

type MappingDefinition

type MappingDefinition struct {
	Properties     map[string]MappingProperty `json:"properties,omitempty"`
	LooseKeyType   string                     `json:"loose-key-type,omitempty"`
	LooseValueType string                     `json:"loose-value-type,omitempty"`
}

type MappingProperty

type MappingProperty struct {
	Type     string `json:"type,omitempty"`
	Required bool   `json:"required,omitempty"`
}

func (*MappingProperty) UnmarshalJSON

func (s *MappingProperty) UnmarshalJSON(data []byte) error

type Node

type Node struct {
	RestrictEval bool
	Definition   string
	Schema       *Schema
	Context      []string
}

func (*Node) GetFunctions

func (s *Node) GetFunctions() []FunctionInfo

func (*Node) GetNestedNode added in v0.4.0

func (s *Node) GetNestedNode(path ...string) *Node

func (*Node) GetVariables added in v0.4.0

func (s *Node) GetVariables() []string

func (*Node) UnmarshalYAML

func (s *Node) UnmarshalYAML(node *yaml.Node) error

func (*Node) ValidateExpression added in v0.4.0

func (s *Node) ValidateExpression(node *yaml.Node, allowedVars map[string]struct{}, allowedFuncs map[string]struct{}) bool

ValidateExpression checks whether all variables and functions used in the expressions inside the provided yaml.Node are present in the allowed sets. It returns false if any variable or function is missing.

type NullDefinition

type NullDefinition struct {
}

type NumberDefinition

type NumberDefinition struct {
}

type OddFunctionInfo added in v0.4.0

type OddFunctionInfo struct {
	BasicFunctionInfo
}

func (OddFunctionInfo) Check added in v0.4.0

func (f OddFunctionInfo) Check(args []exprparser.Node) error

type Schema

type Schema struct {
	Definitions map[string]Definition
}

func GetActionSchema

func GetActionSchema() *Schema

func GetGiteaWorkflowSchema added in v0.4.0

func GetGiteaWorkflowSchema() *Schema

func GetWorkflowSchema

func GetWorkflowSchema() *Schema

func (*Schema) GetDefinition

func (s *Schema) GetDefinition(name string) Definition

type SequenceDefinition

type SequenceDefinition struct {
	ItemType string `json:"item-type"`
}

type StringDefinition

type StringDefinition struct {
	Constant     string `json:"constant,omitempty"`
	IsExpression bool   `json:"is-expression,omitempty"`
}

type ValidationError added in v0.4.0

type ValidationError struct {
	Kind ValidationKind
	Location
	Message string
}

func (ValidationError) Error added in v0.4.0

func (e ValidationError) Error() string

type ValidationErrorCollection added in v0.4.0

type ValidationErrorCollection struct {
	Errors      []ValidationError
	Collections []ValidationErrorCollection
}

func AsValidationErrorCollection added in v0.4.0

func AsValidationErrorCollection(err error) *ValidationErrorCollection

func (*ValidationErrorCollection) AddError added in v0.4.0

func (c *ValidationErrorCollection) AddError(err ValidationError)

func (ValidationErrorCollection) Error added in v0.4.0

type ValidationKind added in v0.4.0

type ValidationKind int
const (
	ValidationKindFatal ValidationKind = iota
	ValidationKindWarning
	ValidationKindInvalidProperty
	ValidationKindMismatched
	ValidationKindMissingProperty
)

Jump to

Keyboard shortcuts

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