Documentation
¶
Index ¶
- Constants
- func Apply(ctx context.Context, db *sql.DB, opts ApplyOptions) (any, error)
- func BundleFiles(files []File) (fs.FS, error)
- func Decode(data []byte, value any) error
- func Unwrap(data []byte) (json.RawMessage, []string, error)
- func Validate(opts ApplyOptions) error
- func Variables(values []string) (map[string]cty.Value, error)
- type ApplyOptions
- type ContentKind
- type File
- type Options
- type PlanResult
- type Project
- type ProjectConfig
- type ProjectPreview
- type ProjectSource
- type ProjectUpload
- type RunOptions
- type RunResult
- type Source
- type Step
Constants ¶
const ProjectConfigName = ".sqlglot-go.yaml"
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(opts ApplyOptions) error
Validate checks an artifact's integrity and acknowledgements without opening a database. Each artifact carries its own hash, which guards only that the file is what its planner wrote.
Types ¶
type ApplyOptions ¶
type ApplyOptions struct {
Dialect string
Schema string
Artifact json.RawMessage
Acks []string
LockTimeout time.Duration
CSV csvdata.Options
}
ApplyOptions applies an artifact as reviewed: its own hash guards its integrity, and Acks acknowledge its destructive steps.
type ContentKind ¶ added in v1.3.0
type ContentKind string
ContentKind is what a bundle file holds: SQL scripts or HCL schema.
const ( SQLContent ContentKind = "sql" HCLContent ContentKind = "hcl" )
func DetectContent ¶ added in v1.3.0
func DetectContent(name, content string) (ContentKind, bool)
DetectContent is the kind of the file name holding content. A .sql or .hcl name is that kind whatever it holds, so its loader reports what is wrong with it. Any other file is HCL when it parses as an HCL body declaring something, SQL when its first word past comments opens a SQL statement, and neither otherwise.
type File ¶
func ClassifyFiles ¶ added in v1.3.0
ClassifyFiles names every file by the kind DetectContent finds, since the bundle loaders select files by extension: a .sql or .hcl path is kept, any other path's extension becomes the kind's. A file of neither kind, or two files named alike once classified, is an error.
type PlanResult ¶
type PlanResult struct {
Dialect string `json:"dialect"`
Schema string `json:"schema"`
Artifact json.RawMessage `json:"artifact"`
Hash string `json:"hash"`
Acks []string `json:"acks"`
Steps []Step `json:"steps"`
Changes []native.Change `json:"changes"`
Warnings []string `json:"warnings"`
Applicable bool `json:"applicable"`
SQL string `json:"sql"`
Sources []ProjectSource `json:"sources,omitempty"`
CSVPlan *csvdata.Artifact `json:"csvPlan,omitempty"`
// ScriptPlan is the plan file of a SQL Server script bundle.
ScriptPlan *scriptplan.PlanFile `json:"scriptPlan,omitempty"`
Original json.RawMessage `json:"-"`
}
type Project ¶ added in v1.3.3
type Project struct {
// contains filtered or unexported fields
}
func LoadProject ¶ added in v1.3.3
LoadProject resolves the configured project sources. A nil project means the filesystem has no source mappings.
func (*Project) Preview ¶ added in v1.3.3
func (project *Project) Preview() ProjectPreview
type ProjectConfig ¶ added in v1.3.3
type ProjectConfig struct {
Version int `yaml:"version"`
Mappings []projectMapping `yaml:"mappings"`
Ignore []string `yaml:"ignore"`
Connections map[string]string `yaml:"connections" json:"-"`
}
func ReadProjectConfig ¶ added in v1.3.3
func ReadProjectConfig(fsys fs.FS) (*ProjectConfig, error)
ReadProjectConfig reads a YAML config without opening migration files or targets.
type ProjectPreview ¶ added in v1.3.3
func PreviewProject ¶ added in v1.3.3
func PreviewProject(files []File) (ProjectPreview, error)
PreviewProject validates uploaded files without opening a database.
type ProjectSource ¶ added in v1.3.3
type ProjectUpload ¶ added in v1.3.3
type ProjectUpload struct {
Required []string `json:"required"`
Plain bool `json:"plain,omitempty"`
}
func ProjectUploadPaths ¶ added in v1.3.3
func ProjectUploadPaths(config string, paths []string) (ProjectUpload, error)
ProjectUploadPaths finds the files needed to run the same mapper used by the CLI. A transform may read files under the matched file's directory.
type RunOptions ¶
type RunOptions struct {
Mode string
Target dbtarget.OpenOptions
Plan Options
Acks []string
ArtifactContent json.RawMessage
LockTimeout string
}