tbls: github.com/k1LoW/tbls/config Index | Files

package config

import "github.com/k1LoW/tbls/config"

Index

Package Files

config.go lint.go

Constants

const DefaultERFormat = "png"

DefaultERFormat is default ER diagram format

type AdditionalComment Uses

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 Uses

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 Uses

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

ColumnCount checks table column count

func (ColumnCount) Check Uses

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

Check table column count

func (ColumnCount) IsEnabled Uses

func (r ColumnCount) IsEnabled() bool

IsEnabled return Rule is enabled or not

type Config Uses

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"`
    LintExclude []string             `yaml:"lintExclude"`
    Relations   []AdditionalRelation `yaml:"relations"`
    Comments    []AdditionalComment  `yaml:"comments"`
}

Config is tbls config

func NewConfig Uses

func NewConfig() (*Config, error)

NewConfig return Config

func (*Config) ExcludeTables Uses

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

ExcludeTables exclude tables from schema.Schema

func (*Config) Load Uses

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

Load load config with all method

func (*Config) LoadConfigFile Uses

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

LoadConfigFile load config file

func (*Config) LoadEnviron Uses

func (c *Config) LoadEnviron() error

LoadEnviron load environment variables

func (*Config) MaskedDSN Uses

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

MaskedDSN return DSN mask password

func (*Config) MergeAdditionalData Uses

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

MergeAdditionalData merge additional* to schema.Schema

func (*Config) ModifySchema Uses

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

ModifySchema modify schema.Schema by config

type DuplicateRelations Uses

type DuplicateRelations struct {
    Enabled bool `yaml:"enabled"`
}

DuplicateRelations checks duplicate table relations

func (DuplicateRelations) Check Uses

func (r DuplicateRelations) Check(s *schema.Schema, exclude []string) []RuleWarn

Check duplicate table relations

func (DuplicateRelations) IsEnabled Uses

func (r DuplicateRelations) IsEnabled() bool

IsEnabled return Rule is enabled or not

type ER Uses

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

ER is er diagram setting

type Format Uses

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

Format is document format setting

type Lint Uses

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

Lint is the struct for lint config

type Option Uses

type Option func(*Config) error

Option function change Config

func Adjust Uses

func Adjust(adjust bool) Option

Adjust return Option set Config.Format.Adjust

func DSN Uses

func DSN(dsn string) Option

DSN return Option set Config.DSN

func DocPath Uses

func DocPath(docPath string) Option

DocPath return Option set Config.DocPath

func ERFormat Uses

func ERFormat(erFormat string) Option

ERFormat return Option set Config.ER.Format

func ERSkip Uses

func ERSkip(skip bool) Option

ERSkip return Option set Config.ER.Skip

func Sort Uses

func Sort(sort bool) Option

Sort return Option set Config.Format.Sort

type RequireColumnComment Uses

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

RequireColumnComment checks column comment

func (RequireColumnComment) Check Uses

func (r RequireColumnComment) Check(s *schema.Schema, exclude []string) []RuleWarn

Check column comment

func (RequireColumnComment) IsEnabled Uses

func (r RequireColumnComment) IsEnabled() bool

IsEnabled return Rule is enabled or not

type RequireColumns Uses

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

RequireColumns checks if the table has specified columns

func (RequireColumns) Check Uses

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

Check the existence of a table columns

func (RequireColumns) IsEnabled Uses

func (r RequireColumns) IsEnabled() bool

IsEnabled return Rule is enabled or not

type RequireColumnsColumn Uses

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

RequireColumnsColumn is required column

type RequireForeignKeyIndex Uses

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

RequireForeignKeyIndex checks if the foreign key columns have an index

func (RequireForeignKeyIndex) Check Uses

func (r RequireForeignKeyIndex) Check(s *schema.Schema, exclude []string) []RuleWarn

Check if the foreign key columns have an index

func (RequireForeignKeyIndex) IsEnabled Uses

func (r RequireForeignKeyIndex) IsEnabled() bool

IsEnabled return Rule is enabled or not

type RequireTableComment Uses

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

RequireTableComment checks table comment

func (RequireTableComment) Check Uses

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

Check table comment

func (RequireTableComment) IsEnabled Uses

func (r RequireTableComment) IsEnabled() bool

IsEnabled return Rule is enabled or not

type Rule Uses

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

Rule is interfece of `tbls lint` cop

type RuleWarn Uses

type RuleWarn struct {
    Target  string
    Message string
}

RuleWarn is struct of Rule error

type UnrelatedTable Uses

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

UnrelatedTable checks isolated table

func (UnrelatedTable) Check Uses

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

Check table relation

func (UnrelatedTable) IsEnabled Uses

func (r UnrelatedTable) IsEnabled() bool

IsEnabled return Rule is enabled or not

Package config imports 13 packages (graph) and is imported by 5 packages. Updated 2020-01-10. Refresh now. Tools for package owners.