resource

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As[T Resource](r Resource) (T, error)

func GetAs

func GetAs[T Resource](mgr Manager, ref string) (T, error)

func GetManyAs

func GetManyAs[T Resource](mgr Manager, refs []string) ([]T, error)

func MakeJSONSchema

func MakeJSONSchema(schemaStr string, reqdSchemas ...string) (*gojsonschema.Schema, error)

Types

type ErrUnexpectedType added in v0.2.0

type ErrUnexpectedType struct {
	Actual       any
	ExpectedType string
}

func NewErrUnexpectedType added in v0.2.0

func NewErrUnexpectedType(actual any, expectedType string) *ErrUnexpectedType

func (*ErrUnexpectedType) Error added in v0.2.0

func (err *ErrUnexpectedType) Error() string

type Manager

type Manager interface {
	Initialize() error

	TypeNames() []string
	FilePartialPaths(typeName string) []string

	Add(string, Resource)
	Get(string) (Resource, error)
	Clear()
}

func NewManager

func NewManager(rootDir string, reg TypeRegistry) Manager

type Resource

type Resource interface {
	Initialize(Manager) error
}

type Type

type Type interface {
	Name() string
	Load(path string) (Resource, error)
}

type TypeRegistry

type TypeRegistry = registry.Registry[Type]

Directories

Path Synopsis
Package mock_resource is a generated GoMock package.
Package mock_resource is a generated GoMock package.

Jump to

Keyboard shortcuts

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