lib

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShard        = 0
	MetaDirectory       = ".dvc"
	PermissionsFile     = ".dvc/permissions.json"
	ConfigFilePath      = ".dvc/config.json"
	SchemasFilePath     = ".dvc/schemas.json"
	ChangeFilePath      = ".dvc/changes.log"
	TablesCacheFilePath = ".dvc/tables-cache.json"
	RoutesFilePath      = ".dvc/routes.json"
	ModelsDir           = "models"
	IntegrationsDir     = "integrations"
	DALsDir             = "dals"
)
View Source
const (
	// OptLogInfo triggers verbose logging
	OptLogInfo = 1 << iota
	// OptLogDebug triggers extremely verbose logging
	OptLogDebug
	// OptSilent suppresses all logging
	OptSilent
	// OptReverse reverses the function
	OptReverse
	// OptSummary shows a summary of the actions instead of a raw stdout dump
	OptSummary
	// OptClean cleans
	OptClean
	// OptForce forces
	OptForce
)

Variables

This section is empty.

Functions

func DirExists

func DirExists(dirPath string) bool

func DirIsEmpty

func DirIsEmpty(dirPath string) bool

func EnsureDir

func EnsureDir(dir string) (e error)

EnsureDir creates a new dir if the dir is not found

func ExtractRootNameFromKey

func ExtractRootNameFromKey(key string) string

func FetchDirFileNames

func FetchDirFileNames(dirPath string) (fileNames []string, e error)

FetchDirFileNames fetches returns a slice of strings of the name of the directories in a directory (non-recursive)

func FetchFile

func FetchFile(filePath string) (changesetFileString string, e error)

FetchFile fetches a file contents

func FetchNonDirFileNames

func FetchNonDirFileNames(dirPath string) (files []string, e error)

FetchNonDirFileNames returns a list of files in a directory that are only regular files

func FileExists

func FileExists(filePath string) bool

func FmtGoCode

func FmtGoCode(filePath string) (e error)

FmtGoCode formats a go file

func FormatCode

func FormatCode(code string) ([]byte, error)

FormatCode formats the code

func FormatFieldList

func FormatFieldList(src []byte, fieldList *ast.FieldList, pkgName string) (fields []string)

FormatFieldList returns a list of formatted list of fields

func GetFuncDeclarationReceiverType

func GetFuncDeclarationReceiverType(fd *ast.FuncDecl) (expr ast.Expr, e error)

GetFuncDeclarationReceiverType returns the receiver type of a function declaration

func GetReceiverTypeName

func GetReceiverTypeName(src []byte, fl interface{}) (name string, funcDef *ast.FuncDecl)

GetReceiverTypeName returns the name of the receiver type and the declaration

func HashFileMd5

func HashFileMd5(filePath string) (string, error)

HashFileMd5 returns an MD5 checksum of the file at `filePath`

func HashStringMd5

func HashStringMd5(s string) string

HashStringMd5 genereates an MD5 hash of a string

func ReadCliInput

func ReadCliInput(reader *bufio.Reader, title string) string

func RunCommand

func RunCommand(name string, args ...string) (stdout string, stderr string, exitCode int)

RunCommand runs a system command

func WriteGoCodeToFile

func WriteGoCodeToFile(goCode string, filePath string) (e error)

WriteGoCodeToFile writes a string of golang code to a file and then formats it with `go fmt`

func WriteSQLToLog

func WriteSQLToLog(sql string) error

Types

type CLITable

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

func NewCLITable

func NewCLITable(colNames []string) *CLITable

func (*CLITable) AddRow

func (c *CLITable) AddRow(row []string)

func (*CLITable) Col

func (c *CLITable) Col(val string)

func (*CLITable) Colf

func (c *CLITable) Colf(template string, args ...interface{})

func (*CLITable) NewRow

func (c *CLITable) NewRow() []string

func (*CLITable) Row

func (c *CLITable) Row()

func (*CLITable) String

func (c *CLITable) String() string

type ChangeFile

type ChangeFile struct {
	ID          int64
	DateCreated int64
	Hash        string
	Name        string
	DVCSetID    int64
	IsRun       bool
	IsDeleted   bool
	Content     string
	FullPath    string
	Ordinal     int
}

ChangeFile represents both a physical file on the local file system along with the entry in the changefile database

type Changeset

type Changeset struct {
	ChangeFiles map[string]ChangeFile
	Signature   string
}

Changeset represents all of the changes in an environment and their changes

type Command

type Command struct {
	Options Options
}

Command is the command line functionality

type Config

type Config struct {
	ChangeSetPath string            `json:"changesetPath"`
	BasePackage   string            `json:"basePackage"`
	Databases     []*ConfigDatabase `json:"Databases"`
	Packages      struct {
		Cache    string `json:"cache"`
		Models   string `json:"models"`
		Schema   string `json:"schema"`
		Repos    string `json:"repos"`
		Services string `json:"services"`
		API      string `json:"api"`
	} `json:"packages"`

	Dirs struct {
		Dals                  string `json:"dals"`
		DalInterfaces         string `json:"dalInterfaces"`
		Repos                 string `json:"repos"`
		Cache                 string `json:"cache"`
		Models                string `json:"models"`
		Integrations          string `json:"integrations"`
		IntegrationInterfaces string `json:"integrationInterfaces"`
		Aggregates            string `json:"aggregates"`
		Schema                string `json:"schema"`
		Typescript            string `json:"typescript"`
		Services              string `json:"services"`
		ServiceInterfaces     string `json:"serviceInterfaces"`
		Controllers           string `json:"controllers"`
		API                   string `json:"api"`
		Permissions           string `json:"permissions"`
	} `json:"dirs"`
}

Config contains a set of configuration values used throughout the application

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads a config file

type ConfigDatabase

type ConfigDatabase struct {
	Key       string            `json:"key"`
	Type      string            `json:"type"`
	User      string            `json:"user"`
	Pass      string            `json:"pass"`
	Host      string            `json:"host"`
	Name      string            `json:"name"`
	Enums     []string          `json:"enums"`
	OneToMany map[string]string `json:"onetomany"`
	OneToOne  map[string]string `json:"onetoone"`
	ManyToOne map[string]string `json:"manytoone"`
}

func GetDatabasesByRootName

func GetDatabasesByRootName(rootName string, config *Config) []*ConfigDatabase

GetDatabaseByName gets all databases that have the name of `name` as the base and includes shards with `_[shardNo]` as the suffix.

type DatabaseType

type DatabaseType string

DatabaseType is the type of database to be used.

const (
	// DatabaseTypeMysql is the MySQL flavor of database
	DatabaseTypeMysql DatabaseType = "mysql"
	// DatabaseTypeSqlite is the Sqlite flavor of database
	DatabaseTypeSqlite DatabaseType = "sqlite"
)

type Files

type Files struct {
}

Files contains functionality pertaining to files

func (*Files) BuildChangeFile

func (f *Files) BuildChangeFile(sqlPath string, ordinal int) (changeFile *ChangeFile, e error)

BuildChangeFile builds a changeFile object based on a path and an ordinal

func (*Files) BuildChangeFiles

func (f *Files) BuildChangeFiles(sqlPaths []string) (changeFiles []ChangeFile, e error)

BuildChangeFiles returns a collection of ChangeFile objects based on a collection of sql paths

func (*Files) FetchLocalChangesetList

func (f *Files) FetchLocalChangesetList(rootPath string) (sqlPaths []string, e error)

FetchLocalChangesetList gets the contents of the changesets.json file and returns a collection of paths ([]string)

func (*Files) ScanDir

func (f *Files) ScanDir(rootPath string, extension string) (paths []string, e error)

ScanDir scans the changeset directory for any file with an extension

type GoFileImports

type GoFileImports []string

GoFileImports is a collection of imports for a model file

func (*GoFileImports) Append

func (i *GoFileImports) Append(m string)

Append adds to the collection of imports

func (*GoFileImports) Get

func (i *GoFileImports) Get(idx int) string

Get returns an import at an index

func (*GoFileImports) Len

func (i *GoFileImports) Len() int

Len returns the length of the collection of imports

func (*GoFileImports) ToString

func (i *GoFileImports) ToString() string

ToString returns a string representation of imports on a go file

type GoStruct

type GoStruct struct {
	Package  string
	Name     string
	Fields   *GoStructFields
	Methods  *GoStructMethods
	Comments string
	Imports  *GoFileImports
}

GoStruct represents a model struct

func NewGoStruct

func NewGoStruct() *GoStruct

NewGoStruct returns a new GoStruct

type GoStructField

type GoStructField struct {
	Name     string
	DataType string
	Tags     []*GoStructFieldTag
	Comments string
}

GoStructField is a field on a Model struct

func (*GoStructField) ToString

func (m *GoStructField) ToString() string

ToString returns a tring representation of a go struct field

type GoStructFieldTag

type GoStructFieldTag struct {
	Name    string
	Value   string
	Options []string
}

GoStructFieldTag is a tag on a field on a model struct

func (*GoStructFieldTag) ToString

func (t *GoStructFieldTag) ToString() string

ToString returns a string representation of a go struct field tag

type GoStructFields

type GoStructFields []*GoStructField

GoStructFields is a collection of a go struct fields

func (*GoStructFields) Append

func (i *GoStructFields) Append(m *GoStructField)

Append adds to the collection of imports

func (*GoStructFields) Get

func (i *GoStructFields) Get(idx int) *GoStructField

Get returns an import at an index

func (*GoStructFields) Len

func (i *GoStructFields) Len() int

Len returns the length of the collection of imports

type GoStructMethod

type GoStructMethod struct {
	Code string
	Docs []string
}

GoStructMethod is a method on a struct

type GoStructMethods

type GoStructMethods []*GoStructMethod

GoStructMethods is a collection of go methods on a struct

func (*GoStructMethods) Append

func (g *GoStructMethods) Append(m *GoStructMethod)

Append adds a new struct to the struct collection

func (*GoStructMethods) Get

func (g *GoStructMethods) Get(index int) (m *GoStructMethod)

Get gets a struct at index

func (*GoStructMethods) Len

func (g *GoStructMethods) Len() int

Len returns the number of methods

type Method

type Method struct {
	Code      string
	Documents []string
}

Method describes code and Documents for a method

func ParseStruct

func ParseStruct(src []byte, structName string, copyDocuments bool, copyTypeDocuments bool, pkgName string) (methods []Method, imports []string, typeDoc string)

ParseStruct parses a struct

func (*Method) Lines

func (m *Method) Lines() []string

Lines return a a slice of documentation and code

type Options

type Options uint

Options are the available runtime flags

Jump to

Keyboard shortcuts

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