types

package
v2.0.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package types implements migrate related interfaces and models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	Execute(name string, out io.Writer, args []string) error
}

Command defines an interface for a command which is executable.

type DNSRecords

type DNSRecords []*v1dns.ResourceRecordSet

DNSRecords represents an abstraction for dns record sets collection.

type Direction

type Direction int

Direction defines the type of the migration direction.

const (
	// DirectionUp indicates the direction type is forward.
	DirectionUp Direction = iota + 1

	// DirectionDown indicates the direction type is backward (rollback).
	DirectionDown
)

func (Direction) MarshalJSON

func (r Direction) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string.

func (Direction) String

func (r Direction) String() string

type Executable

type Executable interface {
	Execute(out io.Writer, args []string) error
}

Executable defines an interface for the execute command of the root command executable method when it is passed through the chain of chained commands.

type Executor

type Executor struct {
	Name    string
	Command Command
}

Executor is a wrapper class for passing a specialized executable root object across chained commands.

func (Executor) Execute

func (r Executor) Execute(out io.Writer, args []string) error

Execute defines a method for executing the root command in the chainable command sequence.

type Migration

type Migration struct {
	Name string         `json:"name,omitempty" yaml:"name,omitempty"`
	Tag  semver.Version `json:"tag,omitempty" yaml:"tag,omitempty"`
	Up   []Operation    `json:"up,omitempty" yaml:"up,omitempty"`
	Down []Operation    `json:"down,omitempty" yaml:"down,omitempty"`
}

Migration defines a set of operations to run on the database.

type Migrations

type Migrations []*Migration

Migrations represents multiple database migrations.

func (Migrations) Len

func (r Migrations) Len() int

Len returns length of migrations collection

func (Migrations) Less

func (r Migrations) Less(i, j int) bool

Less checks if migration at index i is less than migration at index j

func (Migrations) Swap

func (r Migrations) Swap(i, j int)

Swap swaps two migrations inside the collection by its indices

type OpExecutor

type OpExecutor interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Insert(list ...interface{}) error
	Delete(list ...interface{}) (int64, error)
}

OpExecutor describes an abstract database operations executor.

type Operation

type Operation struct {
	Query     string `json:"query,omitempty" yaml:"query,omitempty"`
	DisableTx bool   `json:"disableTx,omitempty" yaml:"disableTx,omitempty"`
}

Operation defines a single query operation to run on the database.

func (Operation) Execute

func (r Operation) Execute(db *store.Context, migration *Migration, d Direction) error

Execute runs the query operation on the database.

type Patch

type Patch struct {
	Filters []string
	Func    func(ctx context.Context, out io.Writer) error
	// contains filtered or unexported fields
}

Patch defines an executable patch function and filters for which this function will run.

func (*Patch) Do

func (r *Patch) Do(ctx context.Context, out io.Writer) error

Do executes the patch function once and prevents repeated execution.

type Patches

type Patches []*Patch

Patches implements a collection of patching elements each of which executes a pre-execution hook function.

func (*Patches) Filter

func (r *Patches) Filter(name string) *Patches

Filter is a method which allows filtering specific patches based on a command chaining path.

type PsqlDSN

type PsqlDSN struct {
	Host                    string `json:"host" yaml:"host"`
	Port                    string `json:"port" yaml:"port"`
	User                    string `json:"user" yaml:"user"`
	Password                string `json:"password" yaml:"password"`
	DBName                  string `json:"dbName" yaml:"dbName"`
	SSLMode                 string `json:"sslMode" yaml:"sslMode"`
	FallbackApplicationName string `json:"fallbackApplicationName" yaml:"fallbackApplicationName"`
	ConnectTimeout          int    `json:"connectTimeout" yaml:"connectTimeout"`
	SSLCert                 string `json:"sslCert" yaml:"sslCert"`
	SSLKey                  string `json:"sslKey" yaml:"sslKey"`
	SSLRootCert             string `json:"sslRootCert" yaml:"sslRootCert"`
}

PsqlDSN config represents a parsed PostgreSQL connection string.

func (PsqlDSN) Driver

func (c PsqlDSN) Driver() string

Driver returns the driver name for PostgresSQL connection string.

func (PsqlDSN) Source

func (c PsqlDSN) Source() string

Source reassembles the parsed PostgreSQL connection string.

type RangeFunc

type RangeFunc func(key, value interface{}) bool

RangeFunc is used to simplify syntax.

type Registry

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

Registry holds stored changes of either database migrations or kubernetes releases.

func (*Registry) Collect

func (r *Registry) Collect(glob string, collection interface{})

Collect iterates over all registered cluster migrations and adds them to the specified migration.

func (*Registry) Load

func (r *Registry) Load(relPath string) (value interface{}, ok bool)

Load returns the change, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Registry) Range

func (r *Registry) Range(fn func(key, value interface{}) bool)

Range calls fn sequentially for each stored registry. If fn returns false, range stops the iteration. `key` represents the path where the change has been registered.

func (*Registry) Store

func (r *Registry) Store(value interface{})

Store stores a change inside of the registry.

type Release

type Release struct {
	Name      string           `json:"name,omitempty" yaml:"name,omitempty"`
	Version   semver.Version   `json:"version,omitempty" yaml:"version,omitempty"`
	Manifests []runtime.Object `json:"manifests,omitempty" yaml:"manifests,omitempty"`
}

Release defines a collection of kubernetes manifests which can be released together as a logical unit.

func (Release) MarshalYAML

func (r Release) MarshalYAML() (interface{}, error)

MarshalYAML implements custom yaml mashal method.

func (Release) String

func (r Release) String() string

String implements the Stringer interface for Release.

func (*Release) UnmarshalJSON

func (r *Release) UnmarshalJSON(b []byte) error

UnmarshalJSON defines custom json unmarshalling procedure.

type Releases

type Releases []*Release

Releases represents a collection of kubernetes releases.

func (Releases) Len

func (r Releases) Len() int

Len returns length of releases collection

func (Releases) Less

func (r Releases) Less(i, j int) bool

Less checks if release at index i is less than release at index j

func (Releases) Swap

func (r Releases) Swap(i, j int)

Swap swaps two releases inside the collection by its indices

type Resource

type Resource interface {
	NewCommand(ctx context.Context, fqn string) *cobra.Command
}

Resource represents a command object that is able to generate commands.

Jump to

Keyboard shortcuts

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