Documentation
¶
Overview ¶
Package scripts carries dbc's sample scripts and new-script templates inside the binary, so a fresh install has working examples without a checkout, and they never go stale against the sdb API of the binary that ships them.
The files beside this one are the samples (named in the embed directive below). Each carries //go:build ignore and is package main, so `go build ./...` never meets them and this package (scripts) never mixes with theirs. The templates are in templates/, built the same way.
scripts/
embed.go ◄─ this package
copy_table.go ◄─ an Example: read-only, Duplicate copies it out
loop_params.go
…
templates/
blank.go ◄─ a Template: what New starts from
copy.go
…
pipelines/, jobs/ ◄─ sample specs (JSON), runnable by name
plugins/ ◄─ sample pipeline plugins, one per kind:
mask_email.go copied into plugins_dir to be loaded
…
Examples are listed after the user's own scripts and never written to (the scripts store, userdata/scripts.go, only touches scripts_dir). A template is filled with connection names on the way out (Fill): it says "{{conn}}" and "{{conn2}}" inside string literals, so the template file stays valid Go that Check passes as it is.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fill ¶
Fill is template name's text with connection names put in: "{{conn}}" becomes the first of conns and "{{conn2}}" the second (the copy template's source and destination). Each is written as a Go string literal (strconv.Quote), so a name with a quote or backslash in it still makes a script that compiles. Missing names become placeholders.
func IsExample ¶
IsExample reports whether src is, byte for byte apart from line endings, one of the built-in samples: a copy that holds nothing the binary does not already carry. config's warning about the old ./scripts directory uses it, so a dbc checkout (whose ./scripts is these very samples) is not told to move them.
Types ¶
type Example ¶
type Example struct {
Name string `json:"name"` // file name, with .go
Desc string `json:"desc"` // as userdata.DescOf reads it, less the "Sample dbc script: " lead
Text string `json:"-"` // the source; large, so not in a listing
}
Example is one built-in sample script.
func ExampleByName ¶
ExampleByName is the sample called name, with its text.
type Job ¶ added in v0.13.0
type Job struct {
Name string `json:"name"` // file name, with .json
Desc string `json:"desc"`
Text string `json:"-"`
}
Job is one built-in sample job (jobs/*.json): a DAG of the sample pipelines, read-only and runnable by name like the pipelines. Examples are never scheduled — only a job in jobs_dir is — so the sample's cron line is there to copy, not to fire on every machine that runs dbc web.
type Pipeline ¶ added in v0.13.0
type Pipeline struct {
Name string `json:"name"` // file name, with .json
Desc string `json:"desc"` // the spec's own desc
Text string `json:"-"`
}
Pipeline is one built-in sample pipeline (pipelines/*.json): read-only, listed after the user's own as the script examples are, and run by name with `dbc pipeline run NAME` when no pipeline of the user's shadows it.
func PipelineByName ¶ added in v0.13.0
PipelineByName is the sample pipeline called name, with its text.
type PluginExample ¶ added in v0.13.0
type PluginExample struct {
Name string `json:"name"` // file name, with .go
Desc string `json:"desc"` // the header comment's first sentence (userdata.DescOf)
Text string `json:"-"`
}
PluginExample is one built-in sample pipeline plugin (plugins/*.go): a working plugin file of each kind, to copy into plugins_dir — where it is loaded — and change. Unlike the sample pipelines an example plugin is not loaded from the binary: a plugin in the palette is a file the user has, so what they place is what they can open and edit.
func PluginExampleByName ¶ added in v0.13.0
func PluginExampleByName(name string) (PluginExample, bool)
PluginExampleByName is the sample plugin called name (.go optional), with its text.
func PluginExamples ¶ added in v0.13.0
func PluginExamples() []PluginExample
PluginExamples lists the sample plugins by name.