parser

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotatedReadCloser

type AnnotatedReadCloser interface {
	io.ReadCloser
	Annotate() interface{}
}

AnnotatedReadCloser is a wrapper around io.ReadCloser that allows implementations to supply additional information about data that is read.

type Backend

type Backend interface {
	Init(context.Context, ...BackendOption) (io.ReadCloser, error)
}

Backend provides a source for a parser.

func NewEchoBackend

func NewEchoBackend(echo string) Backend

NewEchoBackend returns a new EchoBackend.

type BackendOption

type BackendOption func(Backend)

BackendOption modifies the parser backend. Backends may accept options at creation time, but must accept them at initialization.

func FsDir

func FsDir(dir string) BackendOption

FsDir sets the directory of an FsBackend.

func FsFilters

func FsFilters(skips ...FilterFn) BackendOption

FsFilters adds FilterFns to an FsBackend.

func PodClient

func PodClient(client kubernetes.Interface) BackendOption

PodClient sets the pod client of a PodLogBackend.

func PodName

func PodName(name string) BackendOption

PodName sets the pod name of a PodLogBackend.

func PodNamespace

func PodNamespace(namespace string) BackendOption

PodNamespace sets the pod namespace of a PodLogBackend.

type EchoBackend

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

EchoBackend is a parser backend that uses string input as source.

func (*EchoBackend) Init

func (p *EchoBackend) Init(ctx context.Context, bo ...BackendOption) (io.ReadCloser, error)

Init initializes an EchoBackend.

type FilterFn

type FilterFn func(path string, info os.FileInfo) (bool, error)

A FilterFn filters files when the FsReadCloser walks the filesystem. Returning true indicates the file should be skipped. Returning an error will cause the FsReadCloser to stop walking the filesystem and return.

func SkipDirs

func SkipDirs() FilterFn

SkipDirs skips directories.

func SkipEmpty

func SkipEmpty() FilterFn

SkipEmpty skips empty files.

func SkipNotYAML

func SkipNotYAML() FilterFn

SkipNotYAML skips files that do not have YAML extension.

func SkipPath

func SkipPath(pattern string) FilterFn

SkipPath skips files at a certain path.

type FsBackend

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

FsBackend is a parser backend that uses a filestystem as source.

func NewFsBackend

func NewFsBackend(fs afero.Fs, bo ...BackendOption) *FsBackend

NewFsBackend returns an FsBackend.

func (*FsBackend) Init

func (p *FsBackend) Init(ctx context.Context, bo ...BackendOption) (io.ReadCloser, error)

Init initializes an FsBackend.

type FsReadCloser

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

FsReadCloser implements io.ReadCloser for an Afero filesystem.

func NewFsReadCloser

func NewFsReadCloser(fs afero.Fs, dir string, fns ...FilterFn) (*FsReadCloser, error)

NewFsReadCloser returns an FsReadCloser that implements io.ReadCloser. It walks the filesystem ahead of time, then reads file contents when Read is invoked. It does not follow symbolic links.

func (*FsReadCloser) Annotate

func (r *FsReadCloser) Annotate() interface{}

Annotate returns additional about the data currently being read.

func (*FsReadCloser) Close

func (r *FsReadCloser) Close() error

Close is a no op for an FsReadCloser.

func (*FsReadCloser) Read

func (r *FsReadCloser) Read(p []byte) (n int, err error)

type FsReadCloserAnnotation

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

FsReadCloserAnnotation annotates data for an FsReadCloser.

type Linter

type Linter interface {
	Lint(*Package) error
}

A Linter lints packages.

type NopBackend

type NopBackend struct{}

NopBackend is a parser backend with empty source.

func NewNopBackend

func NewNopBackend(...BackendOption) *NopBackend

NewNopBackend returns a new NopBackend.

func (*NopBackend) Init

func (p *NopBackend) Init(ctx context.Context, bo ...BackendOption) (io.ReadCloser, error)

Init initializes a NopBackend.

type ObjectCreaterTyper

type ObjectCreaterTyper interface {
	runtime.ObjectCreater
	runtime.ObjectTyper
}

ObjectCreaterTyper know how to create and determine the type of objects.

type ObjectLinterFn

type ObjectLinterFn func(runtime.Object) error

ObjectLinterFn lints an object in a package.

func ObjectLinterFns

func ObjectLinterFns(fns ...ObjectLinterFn) []ObjectLinterFn

ObjectLinterFns is a convenience function to pass multiple ObjectLinterFn to a function that cannot accept variadic arguments.

func Or

Or checks that at least one of the passed linter functions does not return an error.

type Package

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

Package is the set of metadata and objects in a package.

func NewPackage

func NewPackage() *Package

NewPackage creates a new Package.

func (*Package) GetMeta

func (p *Package) GetMeta() []runtime.Object

GetMeta gets metadata from the package.

func (*Package) GetObjects

func (p *Package) GetObjects() []runtime.Object

GetObjects gets objects from the package.

type PackageLinter

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

PackageLinter lints packages by applying package and object linter functions to it.

func NewPackageLinter

func NewPackageLinter(pre []PackageLinterFn, perMeta, perObject []ObjectLinterFn) *PackageLinter

NewPackageLinter creates a new PackageLinter.

func (*PackageLinter) Lint

func (l *PackageLinter) Lint(pkg *Package) error

Lint executes all linter functions against a package.

type PackageLinterFn

type PackageLinterFn func(*Package) error

PackageLinterFn lints an entire package. If function applies a check for multiple objects, consider using an ObjectLinterFn.

func PackageLinterFns

func PackageLinterFns(fns ...PackageLinterFn) []PackageLinterFn

PackageLinterFns is a convenience function to pass multiple PackageLinterFn to a function that cannot accept variadic arguments.

type PackageParser

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

PackageParser is a Parser implementation for parsing packages.

func New

func New(meta, obj ObjectCreaterTyper) *PackageParser

New returns a new PackageParser.

func (*PackageParser) Parse

func (p *PackageParser) Parse(ctx context.Context, reader io.ReadCloser) (*Package, error)

Parse is the underlying logic for parsing packages. It first attempts to decode objects recognized by the meta scheme, then attempts to decode objects recognized by the object scheme. Objects not recognized by either scheme return an error rather than being skipped.

type Parser

type Parser interface {
	Parse(context.Context, io.ReadCloser) (*Package, error)
}

Parser is a package parser.

type PodLogBackend

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

PodLogBackend is a parser backend that uses Kubernetes pod logs as source.

func NewPodLogBackend

func NewPodLogBackend(bo ...BackendOption) *PodLogBackend

NewPodLogBackend returns a new PodLogBackend.

func (*PodLogBackend) Init

func (p *PodLogBackend) Init(ctx context.Context, bo ...BackendOption) (io.ReadCloser, error)

Init initializes a PodLogBackend.

Jump to

Keyboard shortcuts

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