config

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileExt = ".fyml"
)

Variables

This section is empty.

Functions

func CleanForChecksum

func CleanForChecksum(raw []byte) []byte

func CleanNormalizeNewlines

func CleanNormalizeNewlines(raw []byte) []byte

func CleanTrim

func CleanTrim(raw []byte) []byte

func CleanTrimLineEnds

func CleanTrimLineEnds(raw []byte) []byte

func Dir

func Dir() (string, error)

Types

type Args

type Args struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
}

type Checksum

type Checksum string

func CalculateChecksum

func CalculateChecksum(raw []byte) Checksum

type Config

type Config struct {
	MigrationSets map[string]*MigrationSet
	Migrations    map[string]*Migration
	Drivers       map[string]*Driver
}

func New

func New() *Config

func (*Config) AddDriver

func (c *Config) AddDriver(driver *Driver) error

func (*Config) AddMigration

func (c *Config) AddMigration(migration *Migration) error

func (*Config) AddMigrationSet

func (c *Config) AddMigrationSet(migrationSet *MigrationSet) error

type Driver

type Driver struct {
	Path     string     `yaml:"-"`
	Metadata Metadata   `yaml:"metadata"`
	Spec     DriverSpec `yaml:"spec"`
}

func (*Driver) EnforceDefaults

func (d *Driver) EnforceDefaults()

func (*Driver) Validate

func (d *Driver) Validate() *Errors

type DriverConfig

type DriverConfig map[string]any

func (DriverConfig) Bool

func (c DriverConfig) Bool(key string) bool

func (DriverConfig) Float

func (c DriverConfig) Float(key string) float64

func (DriverConfig) Has

func (c DriverConfig) Has(key string) bool

func (DriverConfig) Int

func (c DriverConfig) Int(key string) int

func (DriverConfig) String

func (c DriverConfig) String(key string) string

type DriverSpec

type DriverSpec struct {
	Driver string       `yaml:"driver"`
	Config DriverConfig `yaml:"config"`
}

type Errors

type Errors struct {
	Errors []error
}

func Errorf

func Errorf(format string, args ...any) *Errors

func (*Errors) Append

func (e *Errors) Append(err error)

func (*Errors) HasErrors

func (e *Errors) HasErrors() bool

type Filesystem

type Filesystem struct {
	Dir string
}

func NewFilesystem

func NewFilesystem(dir string) *Filesystem

func (*Filesystem) DirFiles

func (f *Filesystem) DirFiles() ([]string, error)

func (*Filesystem) Exists

func (f *Filesystem) Exists(path string) bool

func (*Filesystem) LoadFiles

func (f *Filesystem) LoadFiles(paths []string) ([]*ParsedFile, error)

func (*Filesystem) MkdirAll

func (f *Filesystem) MkdirAll(paths []string) error

func (*Filesystem) TouchFile

func (f *Filesystem) TouchFile(path string, data []byte) error
type Header struct {
	Kind       string `yaml:"kind"`
	ApiVersion string `yaml:"apiVersion"`
}

type Metadata

type Metadata struct {
	Name        string  `yaml:"name"`
	Description string  `yaml:"description"`
	Args        []*Args `yaml:"args"`
}

type Migration

type Migration struct {
	Path     string        `yaml:"-"`
	Metadata Metadata      `yaml:"metadata"`
	Spec     MigrationSpec `yaml:"spec"`
	Checksum Checksum      `yaml:"-"`
}

func (*Migration) EnforceDefaults

func (m *Migration) EnforceDefaults()

func (*Migration) ResolveFiles

func (m *Migration) ResolveFiles() error

func (*Migration) Validate

func (m *Migration) Validate() *Errors

type MigrationRun

type MigrationRun struct {
	Up struct {
		Sql  string `yaml:"sql"`
		File string `yaml:"file"`
	} `yaml:"up"`
	Down struct {
		Sql  string `yaml:"sql"`
		File string `yaml:"file"`
	} `yaml:"down"`
}

type MigrationSet

type MigrationSet struct {
	Path     string           `yaml:"-"`
	Metadata Metadata         `yaml:"metadata"`
	Spec     MigrationSetSpec `yaml:"spec"`
}

func (*MigrationSet) EnforceDefaults

func (m *MigrationSet) EnforceDefaults()

func (*MigrationSet) Validate

func (m *MigrationSet) Validate() *Errors

type MigrationSetNamespace

type MigrationSetNamespace struct {
	Schema string `yaml:"schema"`
	Prefix string `yaml:"prefix"`
}

type MigrationSetSpec

type MigrationSetSpec struct {
	Namespace  MigrationSetNamespace `yaml:"namespace"`
	Migrations []string              `yaml:"migrations"`
}

type MigrationSpec

type MigrationSpec struct {
	Version     string       `yaml:"version"`
	Transaction *bool        `yaml:"transaction,omitempty"`
	Run         MigrationRun `yaml:"run"`
}

type ParsedChunk

type ParsedChunk struct {
	Header   *Header
	Checksum Checksum
	Raw      []byte
}

type ParsedConfig

type ParsedConfig struct {
	Files []*ParsedFile
}

type ParsedFile

type ParsedFile struct {
	Path   string
	Chunks []*ParsedChunk

	Migrations    []*Migration
	MigrationSets []*MigrationSet
	Drivers       []*Driver
}

type Parser

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

func NewParser

func NewParser(fs *Filesystem, logger *fmtx.Logger) *Parser

New initializes parser and default file system.

func (*Parser) LoadAndParse

func (p *Parser) LoadAndParse() (*ParsedConfig, error)

LoadAndParse parses files in a dir and returns ParsedConfig.

type Resource

type Resource interface {
	EnforceDefaults()
	Validate() *Errors
}

Jump to

Keyboard shortcuts

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