metadataobject

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGetFiles

func DefaultGetFiles(yamlFile string) ([]string, error)

DefaultGetFiles is a default implementation for Object.GetFiles

func DefaultWriteDiff

func DefaultWriteDiff(opts DefaultWriteDiffOpts) error

DefaultWriteDiff is the default implementation for Object.WriteDiff

Types

type DefaultWriteDiffOpts

type DefaultWriteDiffOpts struct {
	From Object
	WriteDiffOpts
	ExcludeFilesPatterns []string
}

type ErrParsingMetadataObject

type ErrParsingMetadataObject interface {
	// ObjectName corresponds to metadata object in JSON format
	// eg: source, api_limits etc
	ObjectName() string
	// Filename corresponding to metadata object
	// eg: databases.yaml, actions.yaml
	Filename() string
	// ErrorContext will contain any additional information regarding error
	ErrorContext() string

	// Unwrap will make sure the error returned is unwrappable
	// https://blog.golang.org/go1.13-errors#TOC_3.1.
	Unwrap() error
	error
}

func NewErrParsingMetadataObject

func NewErrParsingMetadataObject(o Object, err error, context ...string) ErrParsingMetadataObject

type Object

type Object interface {
	Build(metadata *yaml.MapSlice) ErrParsingMetadataObject
	Export(metadata yaml.MapSlice) (map[string][]byte, ErrParsingMetadataObject)
	CreateFiles() error
	// GetFiles will return an array of filepaths which make up the metadata object.
	// For example the "sources" metadata key is made up of files like
	// databases.yaml. which then will have !include tags which will branch to include
	// files like databases/<source-name>/tables/tables.yaml
	// this function is expected to return the list of all these files which make up the metadata object
	GetFiles() ([]string, ErrParsingMetadataObject)
	// WriteDiff should be implemented such that it should write the difference
	// between the current object and passed in object on the provided writer
	WriteDiff(WriteDiffOpts) ErrParsingMetadataObject
	Key() string
	Filename() string
	// BaseDirectory will return the parent directory of `Filename()`
	BaseDirectory() string
}

type Objects

type Objects []Object

type WriteDiffOpts

type WriteDiffOpts struct {
	To           Object
	W            io.Writer
	DisableColor bool
}

Jump to

Keyboard shortcuts

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