logschema

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Code generated for package logschema by go-bindata DO NOT EDIT. (@generated) sources: schema.json

Index

Constants

View Source
const (
	// AddField is the type of change when a field was added.
	AddField = "AddField"
	// DeleteField is the type of change when a field was removed.
	DeleteField = "DeleteField"
	// UpdateFieldMeta is the type of change when a field's metadata was changed (i.e. Required, Description).
	UpdateFieldMeta = "UpdateFieldMeta"
	// UpdateValue is the type of change when a field's value type has changed.
	UpdateValue = "UpdateValue"
	// UpdateValueMeta is the type of change when metadata about a field's value type has changed (i.e. TimeFormat, IsEventTime, Indicators).
	UpdateValueMeta = "UpdateValueMeta"
	// UpdateParser is the type of change when a schema's Parser has changed.
	UpdateParser = "UpdateParser"
	// UpdateMeta is the type of change when a schema's metadata has changed (i.e. Schema, Description, ReferenceURL).
	UpdateMeta = "UpdateMeta"
)

nolint:lll

View Source
const MaxDepth = 64

MaxDepth is the maximum nesting depth for a ValueSchema

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func DiffWalk

func DiffWalk(from, to *ValueSchema, walk func(c Change) bool, basePath ...string)

DiffWalk recursively iterates two value schemas and calls `walk` when a change is found. The `basePath` argument is used prepended to the path on each change. You can abort a walk by returning false from the callback.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func ValidateSchema

func ValidateSchema(s *Schema) error

ValidateSchema validates the schema using the JSON schema in schema.json

func ValidationErrors

func ValidationErrors(err error) (result []gojsonschema.ResultError)

Types

type Change

type Change struct {
	Type string
	Path []string
	From interface{}
	To   interface{}
}

Change describes a change somewhere in the Tree of a ValueSchema.

func Diff

func Diff(from, to *Schema) ([]Change, error)

Diff resolves a and b and returns the set of changes to go from a to b.

type CyclicReferenceError

type CyclicReferenceError struct {
	// contains filtered or unexported fields
}

func (*CyclicReferenceError) Cycle

func (e *CyclicReferenceError) Cycle() []string

func (*CyclicReferenceError) Error

func (e *CyclicReferenceError) Error() string

func (*CyclicReferenceError) Path

func (e *CyclicReferenceError) Path() string

func (*CyclicReferenceError) Ref

func (e *CyclicReferenceError) Ref() string

type FieldDiff

type FieldDiff struct {
	A *FieldSchema
	B *FieldSchema
}

func DiffFields

func DiffFields(a, b []FieldSchema) (d []FieldDiff)

DiffFields returns the union of all fields in both sets as list of pairs.

Fields are paired by name. Each pair contains two FieldSchema pointers `A` and `B`. If a field is found in both `a` and `b`, `A` will point to the field in `a` and `B` will point to the field in `b` If a field is only found in `a`, `A` will point to the field in `a` and `B` will be nil If a field is only found in `b`, `A` will be nil and `B` will point to the field in `b`

This function is useful to use when operating on a union of two field sets without losing information about the origin of each field (i.e. when diffing sets of fields)

type FieldSchema

type FieldSchema struct {
	Name        string `json:"name" yaml:"name"`
	Required    bool   `json:"required,omitempty" yaml:"required,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	ValueSchema `yaml:",inline"`
}

type NativeParser added in v1.16.0

type NativeParser struct {
	Name string `json:"name" yaml:"name"`
}

type Parser

type Parser struct {
	CSV       *preprocessors.CSVMatchConfig  `json:"csv,omitempty" yaml:"csv,omitempty"`
	FastMatch *preprocessors.FastMatchConfig `json:"fastmatch,omitempty" yaml:"fastmatch,omitempty"`
	Regex     *preprocessors.RegexConfig     `json:"regex,omitempty" yaml:"regex,omitempty"`
	Native    *NativeParser                  `json:"native,omitempty" taml:"native,omitempty"`
}

type Schema

type Schema struct {
	Schema       string                  `json:"schema,omitempty" yaml:"schema,omitempty"`
	Parser       *Parser                 `json:"parser,omitempty" yaml:"parser,omitempty"`
	Description  string                  `json:"description,omitempty" yaml:"description,omitempty"`
	ReferenceURL string                  `json:"referenceURL,omitempty" yaml:"referenceURL,omitempty"`
	Version      int                     `json:"version" yaml:"version"`
	Definitions  map[string]*ValueSchema `json:"definitions,omitempty" yaml:"definitions,omitempty"`
	Fields       []FieldSchema           `json:"fields" yaml:"fields"`
}

func (*Schema) Clone

func (s *Schema) Clone() *Schema

type ValueSchema

type ValueSchema struct {
	Type        ValueType     `json:"type" yaml:"type"`
	Fields      []FieldSchema `json:"fields,omitempty" yaml:"fields,omitempty"`
	Element     *ValueSchema  `json:"element,omitempty" yaml:"element,omitempty"`
	Target      string        `json:"target,omitempty" yaml:"target,omitempty"`
	Indicators  []string      `json:"indicators,omitempty" yaml:"indicators,omitempty"`
	TimeFormat  string        `json:"timeFormat,omitempty" yaml:"timeFormat,omitempty"`
	IsEventTime bool          `json:"isEventTime,omitempty" yaml:"isEventTime,omitempty"`
}

func InferJSONValueSchema

func InferJSONValueSchema(x interface{}) *ValueSchema

InferJSONValueSchema infers the Value Schema for a JSON value.

It will return `nil` if `x` is `nil` or if it is not one of the types defined in https://golang.org/pkg/encoding/json/#Unmarshal. If distinction between integer numbers and float numbers is required, the value should be unmarshalled using `json.Number` (e.g. json.Decoder.UseNumber()).

func InferTypeValueSchema added in v1.16.0

func InferTypeValueSchema(typ reflect.Type) (*ValueSchema, error)

func Merge

func Merge(a, b *ValueSchema) *ValueSchema

Merge merges to value schemas to a a common schema that can handle both values. The returned value is a fully independent ValueSchema (deep copy). It panics if values a or b are not fully resolved via `Resolve().

func Ref

func Ref(target string) ValueSchema

func Resolve

func Resolve(schema *Schema) (*ValueSchema, error)

Resolve returns a copy of a ValueSchema with all references resolved from a manifest. It fails if a references cannot be resolved, if the nesting level exceeds MaxDepth or if there is a cyclic reference.

func (*ValueSchema) Clone

func (v *ValueSchema) Clone() *ValueSchema

func (*ValueSchema) GoType

func (v *ValueSchema) GoType() (reflect.Type, error)

func (*ValueSchema) NonEmpty

func (v *ValueSchema) NonEmpty() *ValueSchema

NonEmpty scrubs the ValueSchema from any empty object/array schemas.

type ValueType

type ValueType string
const (
	TypeObject    ValueType = "object"
	TypeArray     ValueType = "array"
	TypeTimestamp ValueType = "timestamp"
	TypeRef       ValueType = "ref"
	TypeString    ValueType = "string"
	TypeBoolean   ValueType = "boolean"
	TypeInt       ValueType = "int"
	TypeSmallInt  ValueType = "smallint"
	TypeBigInt    ValueType = "bigint"
	TypeFloat     ValueType = "float"
	TypeJSON      ValueType = "json"
)

func (ValueType) IsComposite

func (t ValueType) IsComposite() bool

Jump to

Keyboard shortcuts

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