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

package config

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

Index

Package Files

config.go lint.go yaml.go

Constants

const DefaultDocPath = "dbdoc"
const DefaultERFormat = "svg"

DefaultERFormat is the default ER diagram format

Variables

var DefaultConfigFilePaths = []string{".tbls.yml", "tbls.yml"}
var DefaultDistance = 1

DefaultDistance is the default distance between tables that display relations in the ER

type AdditionalComment Uses

type AdditionalComment struct {
    Table              string            `yaml:"table"`
    TableComment       string            `yaml:"tableComment,omitempty"`
    ColumnComments     map[string]string `yaml:"columnComments,omitempty"`
    IndexComments      map[string]string `yaml:"indexComments,omitempty"`
    ConstraintComments map[string]string `yaml:"constraintComments,omitempty"`
    TriggerComments    map[string]string `yaml:"triggerComments,omitempty"`
    Labels             []string          `yaml:"labels,omitempty"`
}

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,omitempty"`
}

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 {
    Name        string               `yaml:"name"`
    Desc        string               `yaml:"desc,omitempty"`
    Labels      []string             `yaml:"labels,omitempty"`
    DSN         DSN                  `yaml:"dsn"`
    DocPath     string               `yaml:"docPath"`
    Format      Format               `yaml:"format,omitempty"`
    ER          ER                   `yaml:"er,omitempty"`
    Include     []string             `yaml:"include,omitempty"`
    Exclude     []string             `yaml:"exclude,omitempty"`
    Lint        Lint                 `yaml:"lint,omitempty"`
    LintExclude []string             `yaml:"lintExclude,omitempty"`
    Relations   []AdditionalRelation `yaml:"relations,omitempty"`
    Comments    []AdditionalComment  `yaml:"comments,omitempty"`
    Dict        dict.Dict            `yaml:"dict,omitempty"`
    MergedDict  dict.Dict            `yaml:"-"`
    Path        string               `yaml:"-"`
    // contains filtered or unexported fields
}

Config is tbls config

func New Uses

func New() (*Config, error)

New return Config

func (*Config) FilterTables Uses

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

FilterTables filter 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) LoadConfig Uses

func (c *Config) LoadConfig(in []byte) error

LoadConfig load config from []byte

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) LoadOption Uses

func (c *Config) LoadOption(options ...Option) error

LoadOptions load options

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 relations: comments: to schema.Schema

func (*Config) ModifySchema Uses

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

ModifySchema modify schema.Schema by config

type DSN Uses

type DSN struct {
    URL     string            `yaml:"url"`
    Headers map[string]string `yaml:"headers,omitempty"`
}

func (DSN) MarshalYAML Uses

func (d DSN) MarshalYAML() ([]byte, error)

func (*DSN) UnmarshalYAML Uses

func (d *DSN) UnmarshalYAML(data []byte) error

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,omitempty"`
    Format   string `yaml:"format,omitempty"`
    Comment  bool   `yaml:"comment,omitempty"`
    Distance *int   `yaml:"distance,omitempty"`
    Font     string `yaml:"font,omitempty"`
}

ER is er setting

type Format Uses

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

Format is document format setting

type LabelStyleBigQuery Uses

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

LabelStyleBigQuery checks if labels are in BigQuery style ( https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements )

func (LabelStyleBigQuery) Check Uses

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

Check if labels are in BigQuery style

func (LabelStyleBigQuery) IsEnabled Uses

func (r LabelStyleBigQuery) IsEnabled() bool

IsEnabled return Rule is enabled or not

type Lint Uses

type Lint struct {
    RequireTableComment      RequireTableComment      `yaml:"requireTableComment"`
    RequireColumnComment     RequireColumnComment     `yaml:"requireColumnComment"`
    RequireIndexComment      RequireIndexComment      `yaml:"requireIndexComment"`
    RequireConstraintComment RequireConstraintComment `yaml:"requireConstraintComment"`
    RequireTriggerComment    RequireTriggerComment    `yaml:"requireTriggerComment"`
    UnrelatedTable           UnrelatedTable           `yaml:"unrelatedTable"`
    ColumnCount              ColumnCount              `yaml:"columnCount"`
    RequireColumns           RequireColumns           `yaml:"requireColumns"`
    DuplicateRelations       DuplicateRelations       `yaml:"duplicateRelations"`
    RequireForeignKeyIndex   RequireForeignKeyIndex   `yaml:"requireForeignKeyIndex"`
    LabelStyleBigQuery       LabelStyleBigQuery       `yaml:"labelStyleBigQuery"`
}

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 DSNURL Uses

func DSNURL(dsn string) Option

DSNURL return Option set Config.DSN.URL

func Distance Uses

func Distance(distance int) Option

Distance return Option set Config.ER.Distance

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"`
    ExcludeTables []string `yaml:"excludeTables"`
}

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 RequireConstraintComment Uses

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

RequireConstraintComment checks constraint comment

func (RequireConstraintComment) Check Uses

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

Check constraint comment

func (RequireConstraintComment) IsEnabled Uses

func (r RequireConstraintComment) IsEnabled() bool

IsEnabled return Rule is enabled or not

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 RequireIndexComment Uses

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

RequireIndexComment checks index comment

func (RequireIndexComment) Check Uses

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

Check index comment

func (RequireIndexComment) IsEnabled Uses

func (r RequireIndexComment) 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 RequireTriggerComment Uses

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

RequireTriggerComment checks trigger comment

func (RequireTriggerComment) Check Uses

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

Check trigger comment

func (RequireTriggerComment) IsEnabled Uses

func (r RequireTriggerComment) 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 15 packages (graph) and is imported by 8 packages. Updated 2020-07-09. Refresh now. Tools for package owners.