Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Run ¶
Example (Defer) ¶
out := bytes.Buffer{} errOut := bytes.Buffer{} eng := setupEngine(&out, &errOut) ctx := context.TODO() fn := fnfile.FnDef{ Name: "test", Do: fnfile.Do{ Steps: fnfile.Steps{ fnfile.DeferSpec{ Do: fnfile.Do{ Steps: fnfile.Steps{ fnfile.Sh{ Run: `echo "defer 1: Sub steps of a defer step..."`, }, fnfile.Sh{ Run: `echo "defer 1: run sequentially"`, }, }, }, }, fnfile.DeferSpec{ Do: fnfile.Do{ Steps: fnfile.Steps{ fnfile.Sh{ Run: `echo "defer 2: Deferred function calls are executed in Last In First Out order. This should show up first."`, }, }, }, }, fnfile.Sh{ Run: `echo "Hello, World"`, }, }, }, } panicOnError(eng.Run(ctx, fn)) fmt.Print(out.String())
Output: Hello, World defer 2: Deferred function calls are executed in Last In First Out order. This should show up first. defer 1: Sub steps of a defer step... defer 1: run sequentially
Example (Do_nested) ¶
out := bytes.Buffer{} errOut := bytes.Buffer{} eng := setupEngine(&out, &errOut) ctx := context.TODO() fn := fnfile.FnDef{ Name: "test", Do: fnfile.Do{ Steps: fnfile.Steps{ fnfile.Sh{ Run: `echo "one"`, }, fnfile.Do{ Steps: fnfile.Steps{ fnfile.Sh{ Run: `echo "nested two"`, }, }, }, fnfile.Sh{ Run: `echo "three"`, }, }, }, } panicOnError(eng.Run(ctx, fn)) fmt.Println(out.String())
Output: one nested two three
Example (Do_sh) ¶
out := bytes.Buffer{} errOut := bytes.Buffer{} eng := setupEngine(&out, &errOut) ctx := context.TODO() fn := fnfile.FnDef{ Name: "test", Do: fnfile.Do{ Steps: fnfile.Steps{ fnfile.Sh{ Run: `echo "hello"`, }, }, }, } panicOnError(eng.Run(ctx, fn)) fmt.Println(out.String())
Output: hello
Example (Do_stop_on_failure) ¶
out := bytes.Buffer{} errOut := bytes.Buffer{} eng := setupEngine(&out, &errOut) ctx := context.TODO() fn := fnfile.FnDef{ Name: "test", Do: fnfile.Do{ Steps: fnfile.Steps{ fnfile.Sh{ Run: `echo "first"`, }, fnfile.Sh{ Run: `false`, }, fnfile.Sh{ Run: `echo "last"`, }, }, }, } err := eng.Run(ctx, fn) fmt.Printf("result: %s, error: %s", strings.TrimSpace(out.String()), err)
Output: result: first, error: 1 error occurred: * running sh [false]: exit status 1
type FileFinder ¶
type FileFinder func(dir string, fs StatReadFS) ([]byte, error)
func AmbiguousExtensionFileFinder ¶
func AmbiguousExtensionFileFinder(name string, extensions ...string) FileFinder
type Options ¶
type Options struct {
Writer fnfile.ResponseWriter
}
type Reader ¶
func YamlFileReader ¶
func YamlFileReader(options ...func(readerOptions *YamlFileReaderOptions)) Reader
type StatReadFS ¶
type StatReadFS interface { fs.StatFS fs.ReadFileFS }
type YamlFileReaderOptions ¶
type YamlFileReaderOptions struct { FS StatReadFS FileFinder FileFinder }
Click to show internal directories.
Click to hide internal directories.