Documentation ¶
Overview ¶
Package urknall
See http://urknall.dynport.de for detailed documentation.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DryRun ¶
A shortcut creating and runnign a build from the given target and template with the DryRun flag set to true. This is quite helpful to actually see which commands would be exeucted in the current setting, without actually doing anything.
func OpenLogger ¶
OpenLogger creates a logging facility for urknall using the given writer for output. Note that the resource must be closed!
Example ¶
logger := OpenLogger(os.Stdout) defer logger.Close() // short: defer OpenLogger(os.Stdout).Close()
Output:
Types ¶
type Build ¶
type Build struct { Target // Where to run the build. Template // What to actually build. Env []string // Environment variables in the form `KEY=VALUE`. Confirm func(actions ...*confirm.Action) error // contains filtered or unexported fields }
A build is the glue between a target and template.
Example ¶
package main import ( "log" "github.com/dynport/urknall/cmd" ) func main() { template := &ExampleTemplate{} target, e := NewLocalTarget() if e != nil { log.Fatal(e) } build := &Build{Target: target, Template: template} if e := build.Run(); e != nil { log.Fatal(e) } } // An example template function. This is helpful to render templates that don't // need configuration like the following ExampleTemplate. func AnExampleTemplateFunc(pkg Package) { pkg.AddCommands("example", Shell("echo template func")) } // A simple template with configuration. type ExampleTemplate struct { Parameter string `urknall:"default=example"` Boolean bool `urknall:"required=true"` } // Templates must implement the Render function. func (tmpl *ExampleTemplate) Render(pkg Package) { // Template parameters can be used in go's text/template style. pkg.AddCommands("base", Shell("echo {{ .Parameter }}")) if tmpl.Boolean { // Only add template function if Boolean value is true. pkg.AddTemplate("func", TemplateFunc(AnExampleTemplateFunc)) } } // Need to implement a command. Those come with the default code created by the // `urknall init` method, so in most cases this must not be done manually. type ShellCmd struct { cmd string } func (c *ShellCmd) Shell() string { return c.cmd } // Helper function to easily create a ShellCmd. func Shell(cmd string) cmd.Command { return &ShellCmd{cmd: cmd} }
Output:
type Package ¶
type Package interface { AddTemplate(string, Template) // Add another template, nested below the current one. AddCommands(string, ...cmd.Command) // Add a new task from the given commands. AddTask(string, Task) // Add the given tasks to the package with the given name. }
The package is an interface. It provides the methods used to add tasks to a package. The packages's AddTemplate and AddCommands methods will internally create tasks.
Nesting of templates provides a lot of flexibility as different configurations can be used depending on the greater context.
The first argument of all three Add methods is a string. These strings are used as identifiers for the caching mechanism. They must be unique over all tasks. For nested templates the identifiers are concatenated using ".".
type Target ¶
type Target interface { Command(cmd string) (target.ExecCommand, error) User() string String() string Reset() error }
The target interface is used to describe something a package can be built on.
func NewSshTarget ¶
Create an SSH target. The address is an identifier of the form `[<user>@?]<host>[:port]`. It is assumed that authentication via public key will work, i.e. the remote host has the building user's public key in its authorized_keys file.
func NewSshTargetWithPassword ¶
Special SSH target that uses the given password for accessing the machine. This is required mostly for testing and shouldn't be used in production settings.
type Task ¶
A task is a list of commands. Each task is cached internally, i.e. if an command has been executed already, none of the preceding tasks has changed and neither the command itself, then it won't be executed again. This enhances performance and removes the burden of writing idempotent commands.
type Template ¶
type Template interface {
Render(pkg Package)
}
A template is used to modularize the urknall setting. Templates are rendered into a package and during rendering tasks can be added.
type TemplateFunc ¶
type TemplateFunc func(Package)
This is a short-cut usable for templates without configuration, i.e. where no separate struct is required.
func (TemplateFunc) Render ¶
func (f TemplateFunc) Render(p Package)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
The Command Interfaces
|
The Command Interfaces |
The urknall binary: see http://urknall.dynport.de/docs/binary/ for further information.
|
The urknall binary: see http://urknall.dynport.de/docs/binary/ for further information. |
Util functions that don't fit anywhere else.
|
Util functions that don't fit anywhere else. |