Documentation
¶
Index ¶
- 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 RunOptions
- type RunResult
- type Source
- type Step
Constants ¶
This section is empty.
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"`
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 RunOptions ¶
type RunOptions struct {
Mode string
Target dbtarget.OpenOptions
Plan Options
Acks []string
ArtifactContent json.RawMessage
LockTimeout string
}