config

package
v0.0.0-...-a63ec11 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDatabase = errors.New("database must be managed or have a non-empty URI")
View Source
var ErrManagedDatabaseNoAuthToken = errors.New(`managed databases require an auth token

If you don't have an auth token, you can create one from the sqlc Cloud
dashboard at https://dashboard.sqlc.dev/. If you have an auth token, ensure
you've set it as the value of the SQLC_AUTH_TOKEN environment variable.`)
View Source
var ErrManagedDatabaseNoProject = errors.New(`managed databases require a cloud project

If you don't have a project, you can create one from the sqlc Cloud
dashboard at https://dashboard.sqlc.dev/. If you have a project, ensure
you've set its id as the value of the "project" field within the "cloud"
section of your sqlc configuration. The id will look similar to
"01HA8TWGMYPHK0V2GGMB3R2TP9".`)
View Source
var ErrMissingEngine = errors.New("unknown engine")
View Source
var ErrMissingVersion = errors.New("no version number")
View Source
var ErrNoOutPath = errors.New("no output path")
View Source
var ErrNoPackagePath = errors.New("missing package path")
View Source
var ErrNoPackages = errors.New("no packages")
View Source
var ErrNoQuerierType = errors.New("no querier emit type enabled")
View Source
var ErrPluginBothTypes = errors.New("plugin: `process` and `wasm` cannot both be defined")
View Source
var ErrPluginBuiltin = errors.New("a built-in plugin with that name already exists")
View Source
var ErrPluginExists = errors.New("a plugin with that name already exists")
View Source
var ErrPluginNoName = errors.New("missing plugin name")
View Source
var ErrPluginNoType = errors.New("plugin: field `process` or `wasm` required")
View Source
var ErrPluginNotFound = errors.New("no plugin found")
View Source
var ErrPluginProcessNoCmd = errors.New("plugin: missing process command")
View Source
var ErrUnknownEngine = errors.New("invalid engine")
View Source
var ErrUnknownVersion = errors.New("invalid version number")

Functions

func Validate

func Validate(c *Config) error

Types

type Analyzer

type Analyzer struct {
	Database *bool `json:"database" yaml:"database"`
}

type Cloud

type Cloud struct {
	Organization string `json:"organization" yaml:"organization"`
	Project      string `json:"project" yaml:"project"`
	Hostname     string `json:"hostname" yaml:"hostname"`
	AuthToken    string `json:"-" yaml:"-"`
}

type Codegen

type Codegen struct {
	Out     string    `json:"out" yaml:"out"`
	Plugin  string    `json:"plugin" yaml:"plugin"`
	Options yaml.Node `json:"options" yaml:"options"`
}

TODO: Figure out a better name for this

type CombinedSettings

type CombinedSettings struct {
	Global  Config
	Package SQL
	Go      golang.Options
	JSON    SQLJSON

	// TODO: Combine these into a more usable type
	Codegen Codegen
}

func Combine

func Combine(conf Config, pkg SQL) CombinedSettings

type Config

type Config struct {
	Version   string               `json:"version" yaml:"version"`
	Cloud     Cloud                `json:"cloud" yaml:"cloud"`
	SQL       []SQL                `json:"sql" yaml:"sql"`
	Overrides Overrides            `json:"overrides,omitempty" yaml:"overrides"`
	Plugins   []Plugin             `json:"plugins" yaml:"plugins"`
	Rules     []Rule               `json:"rules" yaml:"rules"`
	Options   map[string]yaml.Node `json:"options" yaml:"options"`
}

func ParseConfig

func ParseConfig(rd io.Reader) (Config, error)

type Database

type Database struct {
	URI     string `json:"uri" yaml:"uri"`
	Managed bool   `json:"managed" yaml:"managed"`
}

type Engine

type Engine string
const (
	EngineMySQL      Engine = "mysql"
	EnginePostgreSQL Engine = "postgresql"
	EngineSQLite     Engine = "sqlite"
)

type Overrides

type Overrides struct {
	Go *golang.GlobalOptions `json:"go,omitempty" yaml:"go"`
}

type Paths

type Paths []string

func (*Paths) UnmarshalJSON

func (p *Paths) UnmarshalJSON(data []byte) error

func (*Paths) UnmarshalYAML

func (p *Paths) UnmarshalYAML(unmarshal func(interface{}) error) error

type Plugin

type Plugin struct {
	Name    string   `json:"name" yaml:"name"`
	Env     []string `json:"env" yaml:"env"`
	Process *struct {
		Cmd string `json:"cmd" yaml:"cmd"`
	} `json:"process" yaml:"process"`
	WASM *struct {
		URL    string `json:"url" yaml:"url"`
		SHA256 string `json:"sha256" yaml:"sha256"`
	} `json:"wasm" yaml:"wasm"`
}

type Rule

type Rule struct {
	Name string `json:"name" yaml:"name"`
	Rule string `json:"rule" yaml:"rule"`
	Msg  string `json:"message" yaml:"message"`
}

type SQL

type SQL struct {
	Name                 string    `json:"name" yaml:"name"`
	Engine               Engine    `json:"engine,omitempty" yaml:"engine"`
	Schema               Paths     `json:"schema" yaml:"schema"`
	Queries              Paths     `json:"queries" yaml:"queries"`
	Database             *Database `json:"database" yaml:"database"`
	StrictFunctionChecks bool      `json:"strict_function_checks" yaml:"strict_function_checks"`
	StrictOrderBy        *bool     `json:"strict_order_by" yaml:"strict_order_by"`
	Gen                  SQLGen    `json:"gen" yaml:"gen"`
	Codegen              []Codegen `json:"codegen" yaml:"codegen"`
	Rules                []string  `json:"rules" yaml:"rules"`
	Analyzer             Analyzer  `json:"analyzer" yaml:"analyzer"`
}

type SQLGen

type SQLGen struct {
	Go   *golang.Options `json:"go,omitempty" yaml:"go"`
	JSON *SQLJSON        `json:"json,omitempty" yaml:"json"`
}

type SQLJSON

type SQLJSON struct {
	Out      string `json:"out" yaml:"out"`
	Indent   string `json:"indent,omitempty" yaml:"indent"`
	Filename string `json:"filename,omitempty" yaml:"filename"`
}

type V1GenerateSettings

type V1GenerateSettings struct {
	Version   string              `json:"version" yaml:"version"`
	Cloud     Cloud               `json:"cloud" yaml:"cloud"`
	Packages  []v1PackageSettings `json:"packages" yaml:"packages"`
	Overrides []golang.Override   `json:"overrides,omitempty" yaml:"overrides,omitempty"`
	Rename    map[string]string   `json:"rename,omitempty" yaml:"rename,omitempty"`
	Rules     []Rule              `json:"rules" yaml:"rules"`
}

func (*V1GenerateSettings) Translate

func (c *V1GenerateSettings) Translate() Config

func (*V1GenerateSettings) ValidateGlobalOverrides

func (c *V1GenerateSettings) ValidateGlobalOverrides() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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