config

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultERFormat = "png"

DefaultERFormat is default ER diagram format

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalComment

type AdditionalComment struct {
	Table          string            `yaml:"table"`
	TableComment   string            `yaml:"tableComment"`
	ColumnComments map[string]string `yaml:"columnComments"`
}

AdditionalComment is the struct for table relation from yaml

type AdditionalRelation

type AdditionalRelation struct {
	Table         string   `yaml:"table"`
	Columns       []string `yaml:"columns"`
	ParentTable   string   `yaml:"parentTable"`
	ParentColumns []string `yaml:"parentColumns"`
	Def           string   `yaml:"def"`
}

AdditionalRelation is the struct for table relation from yaml

type ColumnCount added in v1.8.0

type ColumnCount struct {
	Enabled bool     `yaml:"enabled"`
	Max     int      `yaml:"max"`
	Exclude []string `yaml:"exclude"`
}

ColumnCount check table column count

func (ColumnCount) Check added in v1.8.0

func (r ColumnCount) Check(s *schema.Schema) []RuleWarn

Check table column count

func (ColumnCount) IsEnabled added in v1.8.0

func (r ColumnCount) IsEnabled() bool

IsEnabled return Rule is enabled or not

type Config

type Config struct {
	DSN       string               `yaml:"dsn"`
	DocPath   string               `yaml:"docPath"`
	Format    Format               `yaml:"format"`
	ER        ER                   `yaml:"er"`
	Exclude   []string             `yaml:"exclude"`
	Lint      Lint                 `yaml:"lint"`
	Relations []AdditionalRelation `yaml:"relations"`
	Comments  []AdditionalComment  `yaml:"comments"`
}

Config is tbls config

func NewConfig

func NewConfig() (*Config, error)

NewConfig return Config

func (*Config) ExcludeTables added in v1.12.0

func (c *Config) ExcludeTables(s *schema.Schema) error

ExcludeTables exclude tables from schema.Schema

func (*Config) Load added in v1.9.0

func (c *Config) Load(configPath string, options ...Option) error

Load load config with all method

func (*Config) LoadConfigFile

func (c *Config) LoadConfigFile(path string) error

LoadConfigFile load config file

func (*Config) LoadEnviron added in v1.9.0

func (c *Config) LoadEnviron() error

LoadEnviron load environment variables

func (*Config) MaskedDSN added in v1.10.0

func (c *Config) MaskedDSN() (string, error)

MaskedDSN return DSN mask password

func (*Config) MergeAdditionalData added in v1.8.0

func (c *Config) MergeAdditionalData(s *schema.Schema) error

MergeAdditionalData merge additional* to schema.Schema

func (*Config) ModifySchema added in v1.12.0

func (c *Config) ModifySchema(s *schema.Schema) error

ModifySchema modify schema.Schema by config

type ER added in v1.10.0

type ER struct {
	Skip    bool   `yaml:"skip"`
	Format  string `yaml:"format"`
	Comment bool   `yaml:"comment"`
}

ER is er diagram setting

type Format added in v1.10.0

type Format struct {
	Adjust bool `yaml:"adjust"`
	Sort   bool `yaml:"sort"`
}

Format is document format setting

type Lint added in v1.8.0

type Lint struct {
	RequireTableComment  RequireTableComment  `yaml:"requireTableComment"`
	RequireColumnComment RequireColumnComment `yaml:"requireColumnComment"`
	UnrelatedTable       UnrelatedTable       `yaml:"unrelatedTable"`
	ColumnCount          ColumnCount          `yaml:"columnCount"`
	RequireColumns       RequireColumns       `yaml:"requireColumns"`
}

Lint is the struct for lint config

type Option added in v1.10.0

type Option func(*Config) error

Option function change Config

func Adjust added in v1.10.0

func Adjust(adjust bool) Option

Adjust return Option set Config.Format.Adjust

func DSN added in v1.10.0

func DSN(dsn string) Option

DSN return Option set Config.DSN

func DocPath added in v1.10.0

func DocPath(docPath string) Option

DocPath return Option set Config.DocPath

func ERFormat added in v1.10.0

func ERFormat(erFormat string) Option

ERFormat return Option set Config.ER.Format

func ERSkip added in v1.10.0

func ERSkip(skip bool) Option

ERSkip return Option set Config.ER.Skip

func Sort added in v1.10.0

func Sort(sort bool) Option

Sort return Option set Config.Format.Sort

type RequireColumnComment added in v1.8.0

type RequireColumnComment struct {
	Enabled        bool     `yaml:"enabled"`
	Exclude        []string `yaml:"exclude"`
	ExcludedTables []string `yaml:"excludedTables"`
}

RequireColumnComment check column comment

func (RequireColumnComment) Check added in v1.8.0

Check column comment

func (RequireColumnComment) IsEnabled added in v1.8.0

func (r RequireColumnComment) IsEnabled() bool

IsEnabled return Rule is enabled or not

type RequireColumns added in v1.12.0

type RequireColumns struct {
	Enabled bool                   `yaml:"enabled"`
	Columns []RequireColumnsColumn `yaml:"columns"`
}

RequireColumns check required table columns

func (RequireColumns) Check added in v1.12.0

func (r RequireColumns) Check(s *schema.Schema) []RuleWarn

Check the existence of a table columns

func (RequireColumns) IsEnabled added in v1.12.0

func (r RequireColumns) IsEnabled() bool

IsEnabled return Rule is enabled or not

type RequireColumnsColumn added in v1.12.0

type RequireColumnsColumn struct {
	Name    string   `yaml:"name"`
	Exclude []string `yaml:"exclude"`
}

RequireColumnsColumn is required column

type RequireTableComment added in v1.8.0

type RequireTableComment struct {
	Enabled bool     `yaml:"enabled"`
	Exclude []string `yaml:"exclude"`
}

RequireTableComment check table comment

func (RequireTableComment) Check added in v1.8.0

func (r RequireTableComment) Check(s *schema.Schema) []RuleWarn

Check table comment

func (RequireTableComment) IsEnabled added in v1.8.0

func (r RequireTableComment) IsEnabled() bool

IsEnabled return Rule is enabled or not

type Rule added in v1.8.0

type Rule interface {
	IsEnabled() bool
	Check(*schema.Schema) []RuleWarn
}

Rule is interfece of `tbls lint` cop

type RuleWarn added in v1.8.0

type RuleWarn struct {
	Target  string
	Message string
}

RuleWarn is struct of Rule error

type UnrelatedTable added in v1.8.2

type UnrelatedTable struct {
	Enabled bool     `yaml:"enabled"`
	Exclude []string `yaml:"exclude"`
}

UnrelatedTable check isolated table

func (UnrelatedTable) Check added in v1.8.2

func (r UnrelatedTable) Check(s *schema.Schema) []RuleWarn

Check table relation

func (UnrelatedTable) IsEnabled added in v1.8.2

func (r UnrelatedTable) IsEnabled() bool

IsEnabled return Rule is enabled or not

Jump to

Keyboard shortcuts

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