Documentation
¶
Overview ¶
Package validator is a generated GoMock package.
Index ¶
- Variables
- func FilterCascadeErrors(failures []gojsonschema.ResultError) []gojsonschema.ResultError
- func FormatDeprecatedField(field DeprecatedField) string
- func NormalizeSchemaPath(path string) string
- type DeprecatedField
- type DeprecatedYAMLSchema
- type MockValidator
- type MockValidatorMockRecorder
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ErrSchemaNotFound = errors.New("failed to fetch schema")
Functions ¶
func FilterCascadeErrors ¶
func FilterCascadeErrors(failures []gojsonschema.ResultError) []gojsonschema.ResultError
FilterCascadeErrors drops the generic anyOf and oneOf failures that only restate a more specific failure, so diagnostics point at the offending leaf value instead of every ancestor. The generated schemas wrap most values in anyOf or oneOf to admit YAML functions, null, and deprecated shapes, so one bad leaf otherwise produces a "Must validate one and only one schema" failure at each ancestor.
A composite failure is dropped when another failure lies strictly below its path, or sits at its path and is not itself a composite failure. A composite failure with nothing more specific is kept.
func FormatDeprecatedField ¶ added in v1.224.1
func FormatDeprecatedField(field DeprecatedField) string
FormatDeprecatedField renders a deprecation finding as Markdown. A trailing parenthetical in the replacement is explanatory prose, not part of the YAML path, so it intentionally remains outside inline-code delimiters.
func NormalizeSchemaPath ¶ added in v1.224.1
NormalizeSchemaPath converts dot-number paths emitted by gojsonschema into the position-map format used by the YAML helpers. It is exported for CLI and LSP adapters that combine schema errors and deprecation warnings.
Types ¶
type DeprecatedField ¶ added in v1.224.1
DeprecatedField is a schema-declared compatibility field found in authored YAML. Path uses the same dot/bracket notation as validation errors and YAML positions.
func FindDeprecatedYAMLFields ¶ added in v1.224.1
func FindDeprecatedYAMLFields(atmosConfig *schema.AtmosConfiguration, schemaSource string, yamlContent []byte) ([]DeprecatedField, error)
FindDeprecatedYAMLFields finds authored properties marked with the standard JSON Schema deprecated annotation. The optional x-atmos-replacement field provides guidance emitted alongside the warning. The scanner deliberately follows only local references: remote schemas are still validated normally, but must be a single self-contained document before their annotations can be inspected.
type DeprecatedYAMLSchema ¶ added in v1.224.1
type DeprecatedYAMLSchema struct {
// contains filtered or unexported fields
}
DeprecatedYAMLSchema is a parsed schema that can be reused to scan multiple YAML documents for deprecated fields.
func LoadDeprecatedYAMLSchema ¶ added in v1.224.1
func LoadDeprecatedYAMLSchema(atmosConfig *schema.AtmosConfiguration, schemaSource string) (*DeprecatedYAMLSchema, error)
LoadDeprecatedYAMLSchema loads and parses a schema for reuse when scanning multiple YAML documents.
func (*DeprecatedYAMLSchema) FindYAMLFields ¶ added in v1.224.1
func (s *DeprecatedYAMLSchema) FindYAMLFields(yamlContent []byte) ([]DeprecatedField, error)
FindYAMLFields returns deprecated fields in yamlContent using the parsed schema. The scanner follows only local references.
type MockValidator ¶
type MockValidator struct {
// contains filtered or unexported fields
}
MockValidator is a mock of Validator interface.
func NewMockValidator ¶
func NewMockValidator(ctrl *gomock.Controller) *MockValidator
NewMockValidator creates a new mock instance.
func (*MockValidator) EXPECT ¶
func (m *MockValidator) EXPECT() *MockValidatorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockValidator) ValidateYAMLContent ¶ added in v1.224.0
func (m *MockValidator) ValidateYAMLContent(schema string, yamlContent []byte) ([]gojsonschema.ResultError, error)
ValidateYAMLContent mocks base method.
func (*MockValidator) ValidateYAMLSchema ¶
func (m *MockValidator) ValidateYAMLSchema(schema, sourceFile string) ([]gojsonschema.ResultError, error)
ValidateYAMLSchema mocks base method.
type MockValidatorMockRecorder ¶
type MockValidatorMockRecorder struct {
// contains filtered or unexported fields
}
MockValidatorMockRecorder is the mock recorder for MockValidator.
func (*MockValidatorMockRecorder) ValidateYAMLContent ¶ added in v1.224.0
func (mr *MockValidatorMockRecorder) ValidateYAMLContent(schema, yamlContent any) *gomock.Call
ValidateYAMLContent indicates an expected call of ValidateYAMLContent.
func (*MockValidatorMockRecorder) ValidateYAMLSchema ¶
func (mr *MockValidatorMockRecorder) ValidateYAMLSchema(schema, sourceFile any) *gomock.Call
ValidateYAMLSchema indicates an expected call of ValidateYAMLSchema.
type Validator ¶
type Validator interface {
ValidateYAMLSchema(schema, sourceFile string) ([]gojsonschema.ResultError, error)
// ValidateYAMLContent validates in-memory YAML content (e.g. an unsaved
// editor buffer) instead of a fetched source.
ValidateYAMLContent(schema string, yamlContent []byte) ([]gojsonschema.ResultError, error)
}
func NewYAMLSchemaValidator ¶
func NewYAMLSchemaValidator(atmosConfig *schema.AtmosConfiguration) Validator