utils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractExtensionGVKs

func ExtractExtensionGVKs(extensions map[string]interface{}) []schema.GroupVersionKind

func ExtractPathGVKs

func ExtractPathGVKs(path *spec3.Path) []schema.GroupVersionKind

func FindFiles

func FindFiles(args ...string) ([]string, error)

func IsEmptyYamlDocument

func IsEmptyYamlDocument(document Document) bool

IsEmptyYamlDocument checks if a yaml document is empty (contains only comments)

func IsJson

func IsJson(file string) bool

func IsYaml

func IsYaml(file string) bool

func IsYamlOrJson

func IsYamlOrJson(file string) bool

func ReadDir

func ReadDir(f fs.FS, filepath string) ([]fs.DirEntry, error)

func ReadFile

func ReadFile(f fs.FS, filepath string) ([]byte, error)

func Stat

func Stat(f fs.FS, filepath string) (fs.FileInfo, error)

func VisitSchema

func VisitSchema(name string, s *spec.Schema, visitor SchemaVisitor) *spec.Schema

Types

type Document

type Document = []byte

func SplitYamlDocuments

func SplitYamlDocuments(fileBytes Document) ([]Document, error)

type PostorderVisitor

type PostorderVisitor func(ctx VisitingContext, s *spec.Schema) *spec.Schema

func (PostorderVisitor) VisitAfter

func (f PostorderVisitor) VisitAfter(ctx VisitingContext, s **spec.Schema)

func (PostorderVisitor) VisitBefore

func (f PostorderVisitor) VisitBefore(ctx VisitingContext, s **spec.Schema) bool

type PreorderVisitor

type PreorderVisitor func(ctx VisitingContext, s *spec.Schema) (*spec.Schema, bool)

There is no "left" or "right" on this tree, so no in-order is necessary

func (PreorderVisitor) VisitAfter

func (f PreorderVisitor) VisitAfter(ctx VisitingContext, s **spec.Schema)

func (PreorderVisitor) VisitBefore

func (f PreorderVisitor) VisitBefore(ctx VisitingContext, s **spec.Schema) bool

type SchemaVisitor

type SchemaVisitor interface {
	// Called on a node before its children.
	// Return false to stop exploring this subtree, otherwise return true.
	VisitBefore(ctx VisitingContext, s **spec.Schema) bool

	// Called on a node after its children.
	VisitAfter(ctx VisitingContext, s **spec.Schema)
}

type VisitingContext

type VisitingContext struct {
	// What field of the parent context was traversed to find the current
	// schema
	SchemaField string

	// If ShemaField is a collection, what key is this schema contained within
	// SchemaField
	Key string

	// If ShemaField is a collection, what index is this schema contained within
	// SchemaField
	//
	// Part of a Union with `key` If one is set, the other must be unset
	Index int

	Parent *VisitingContext
}

func (*VisitingContext) WithSubField

func (v *VisitingContext) WithSubField(field, key string) VisitingContext

func (*VisitingContext) WithSubIndex

func (v *VisitingContext) WithSubIndex(field string, idx int) VisitingContext

Jump to

Keyboard shortcuts

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