target

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v1.3.2"

Variables

This section is empty.

Functions

func EvaluateDefines added in v1.1.0

func EvaluateDefines(c *PreConfig, f []byte) ([]byte, error)

func ExpandDefines added in v1.3.0

func ExpandDefines(pc *PreConfig)

func MergeUserDefines added in v1.3.0

func MergeUserDefines(pc *PreConfig, uargv *Args)

Types

type Args

type Args struct {
	ConfigPath   string
	Verbose      bool
	ExtraVerbose bool
	Execute      bool
	Raw          bool
	Demand       MapFlags
	Set          MapValues
}

it would be nice for golang to support bit fields. Bit fields are very elegant solution, hovewer since golang doesnt support them, We must introduce a lot of code, which makes program slower and more complex. Thats why i decided to waste some memory and introduce separate boolean fields. In future if number of those fields will increase we could make it bit fields.

func NewArgsFromCli

func NewArgsFromCli() *Args

type ArgsFlag

type ArgsFlag uint32
const (
	Verbose ArgsFlag = iota
	Execute
	Raw
)

type Config

type Config struct {
	Driver    string
	Base      string
	Targets   []*Target
	PreConfig `yaml:",inline"`
}

these arrays really should be hash tables. deal with it.

func NewConfigFromBytes added in v1.3.2

func NewConfigFromBytes(bf []byte, fpath string, uargv *Args) (*Config, error)

func NewConfigFromPath

func NewConfigFromPath(configPath string, uargv *Args) (*Config, error)

type Ctx

type Ctx struct {
	GetMergeScript func(
		c *Config, dbCtx interface{}, target *Target, args []string) (string, error)
	DbNew    func(*Target) (interface{}, error)
	DbClose  func(dbCtx interface{})
	DbPing   func(dbCtx interface{}) error
	DbExec   func(dbCtx interface{}, stmt string, args ...interface{}) error
	DbSuffix string
}

func (*Ctx) ExecConfig

func (ctx *Ctx) ExecConfig(config *Config, uargs *Args) error

func (*Ctx) ExecDir

func (ctx *Ctx) ExecDir(
	c *Config, db interface{}, dirPath string, uargv *Args,
) error

func (*Ctx) ExecFile

func (ctx *Ctx) ExecFile(
	c *Config, db interface{}, filePath string, uargv *Args,
) error

func (*Ctx) ExecLines

func (ctx *Ctx) ExecLines(
	db interface{},
	cc []string,
	uargv *Args,
) (int, error)

func (*Ctx) ExecPath

func (ctx *Ctx) ExecPath(
	c *Config, db interface{}, path string, uargv *Args,
) error

func (*Ctx) ExecPaths

func (ctx *Ctx) ExecPaths(
	c *Config, db interface{}, paths []string, uargv *Args,
) error

func (*Ctx) ExecTarget

func (ctx *Ctx) ExecTarget(
	basepath string,
	target *Target,
	uargv *Args,
	c *Config,
) error

type Exec

type Exec struct {
	Type    string
	Args    []string
	Err     string
	Execute bool
}

type MapFlags added in v1.3.0

type MapFlags map[string]struct{}

func (*MapFlags) Set added in v1.3.0

func (i *MapFlags) Set(value string) error

func (*MapFlags) String added in v1.3.0

func (i *MapFlags) String() string

type MapValues added in v1.3.0

type MapValues map[string]string

func (*MapValues) Set added in v1.3.0

func (i *MapValues) Set(value string) error

func (*MapValues) String added in v1.3.0

func (i *MapValues) String() string

type PreConfig added in v1.1.0

type PreConfig struct {
	Version string
	/*
		stupid-simple version of C preprocessor ( but in yaml )

		for example if you place:

		defines:
			- db : my_database
			- foo: bar

		will replace any occurrence of
		${db} with my_database and
		${foo} with bar
		ANYWHERE in dp files. It is like preprocessor ->
			dp-file gets loaded (it may be script, table, type and so on...)
			all defines are being 'evaluated' from top to bottom
			file is parsed into yaml structure / executed if sql and so on...

		it also allows for more advanced usage like so:

		defines:
			- db : test_db
			- drop_db : drop database ${db}
			- create_db: create database ${db}

		...

		targets:
			- name: foo
			  ....
			  exec:
			    - type: stmt
				  args: ["${drop_db}", "${create_db}"]

	*/
	Defines []map[string]string
}

preconfig is getting parsed before actual config. preconfig must be contained in any config structure no matter version, it contains version meta data and preprocessor directives

type Target

type Target struct {
	ConnectionString string
	Server           []string
	Database         string
	User             string
	Password         string
	Args             map[string]string
	Exec             []Exec
	Name             string
	OnDemand         bool `yaml:"on_demand"`
}

func (*Target) GetInt

func (t *Target) GetInt(name string, val *int) error

Jump to

Keyboard shortcuts

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