doc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FragmentTypeUnknown indicates this Fragment is unknown
	// and needs to be decoded.
	FragmentTypeUnknown = iota
	// FragmentTypeInvalid indicates that this Fragment could not be parsed
	// or contains syntax errors.
	FragmentTypeInvalid
	// FragmentTypeObject indicates this Fragment contains a Kubernetes Object.
	FragmentTypeObject
	// FragmentTypeModule indicates this Fragment contains a Rego module.
	FragmentTypeModule
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Name  string
	Parts []Fragment
}

Document is a collection of related Fragments.

func ReadDocument

func ReadDocument(in io.Reader) (*Document, error)

ReadDocument reads a stream of Fragments that are separated by a YAML document separator (see https://yaml.org/spec/1.0/#id2561718). The contents of each Fragment is opaque and need not be YAML.

func ReadFile

func ReadFile(filePath string) (*Document, error)

ReadFile reads a Document from the given file path.

type Fragment

type Fragment struct {
	Bytes    []byte
	Type     FragmentType
	Location Location
	// contains filtered or unexported fields
}

Fragment is a parseable portion of a Document.

func NewRegoFragment

func NewRegoFragment(data []byte) (*Fragment, error)

NewRegoFragment decodes the given data and returns a new Fragment of type FragmentTypeModule.

func (*Fragment) Decode

func (f *Fragment) Decode() (FragmentType, error)

Decode attempts to parse the Fragment.

func (*Fragment) IsDecoded

func (f *Fragment) IsDecoded() bool

IsDecoded returns whether this fragment has been decoded to a known fragment type.

func (*Fragment) Object

func (f *Fragment) Object() *unstructured.Unstructured

Object returns the Kubernetes object if there is one.

func (*Fragment) Rego

func (f *Fragment) Rego() *ast.Module

Rego returns the Rego module if there is one.

type FragmentType

type FragmentType int

FragmentType is the parsed content type for the Fragment.

func (FragmentType) String

func (t FragmentType) String() string

type InvalidFragmentErr

type InvalidFragmentErr struct {
	// Type is the fragment type that was expected at the point
	// the error happened.
	Type FragmentType
}

InvalidFragmentErr is an error value returned to indicate to the caller what type of fragment was found to be invalid.

func (*InvalidFragmentErr) Error

func (e *InvalidFragmentErr) Error() string

type Location

type Location struct {
	// Start is the line number this location starts on.
	Start int

	// End is the line number this location ends on.
	End int
}

Location tracks the lines that bound a Fragment within some larger Document.

func (Location) String

func (l Location) String() string

Jump to

Keyboard shortcuts

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