source

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSourceEmpty = fmt.Errorf("invalid source, must specify at least one type of source configuration")

Functions

This section is empty.

Types

type Entry

type Entry map[string]any

Entry is a single sourced entry. It's just a basic map, but makes it much clearer when building lists of this type, as the type syntax can get a bit messy.

func Parse added in v0.9.0

func Parse(data []byte) []Entry

Parse attempts to extract entries from content that is either Jsonnet, JSON or YAML.

It also supports multidoc YAML, and will either return the root object itself if that root is a map[string]any, or if the root is an array, will try returning the contents of said array that are map[string]any's.

type Source

type Source struct {
	Local  *SourceLocal  `json:"local,omitempty"`
	Inline *SourceInline `json:"inline,omitempty"`
	Exec   *SourceExec   `json:"exec,omitempty"`
}

Source is instantiated from configuration and represents a source of catalog files.

func (Source) Backend added in v0.15.0

func (s Source) Backend() (SourceBackend, error)

func (Source) Load

func (s Source) Load(ctx context.Context) ([]*SourceEntry, error)

func (Source) Validate

func (s Source) Validate() error

type SourceBackend added in v0.15.0

type SourceBackend interface {
	String() string
	Load(ctx context.Context) ([]*SourceEntry, error)
}

type SourceEntry

type SourceEntry struct {
	Origin  string
	Content []byte
}

SourceEntry is an entry that has been discovered in a source, with the contents of the source file and an Origin that explains where the entry came from, specific to the type of source that produced it.

func (SourceEntry) Parse

func (e SourceEntry) Parse() ([]Entry, error)

type SourceExec added in v0.9.0

type SourceExec struct {
	Command []string `json:"command"`
}

func (SourceExec) Load added in v0.9.0

func (s SourceExec) Load(ctx context.Context) ([]*SourceEntry, error)

func (SourceExec) String added in v0.15.0

func (s SourceExec) String() string

func (SourceExec) Validate added in v0.9.0

func (s SourceExec) Validate() error

type SourceInline

type SourceInline struct {
	Entries []map[string]any `json:"entries"`
}

func (SourceInline) Load

func (s SourceInline) Load(ctx context.Context) ([]*SourceEntry, error)

func (SourceInline) String added in v0.15.0

func (s SourceInline) String() string

func (SourceInline) Validate added in v0.12.0

func (s SourceInline) Validate() error

type SourceLocal

type SourceLocal struct {
	Files []string `json:"files"`
}

func (SourceLocal) Load

func (s SourceLocal) Load(ctx context.Context) ([]*SourceEntry, error)

func (SourceLocal) String added in v0.15.0

func (s SourceLocal) String() string

func (SourceLocal) Validate added in v0.12.0

func (s SourceLocal) Validate() error

Jump to

Keyboard shortcuts

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