Documentation ¶
Overview ¶
Package deploy implements functionality for building and deploying Go charms.
See the example for how the pieces fit together.
Once built, a gocharm command can build itself (with the -build-charm flag) and deploy itself (with the -deploy-charm flag).
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCharm ¶
func BuildCharm(p BuildCharmParams) error
BuildCharm builds a charm from the data registered in p.Registry and puts the result into p.CharmDir.
func RunMain ¶
RunMain registers any additional hooks needed for all charms and runs any charm build, deploy or hook logic. It assumes that MainFlags and flag.Parse has been called previously.
If any charm-specific flags are set, it will not return - it just exits, otherwise it returns having done nothing else.
Example ¶
package main import ( "flag" "github.com/juju/gocharm/deploy" "github.com/juju/gocharm/hook" ) func main() { // This example demonstrates a complete charm // that does nothing at all. This code would usually be // placed in the main function. r := hook.NewRegistry() r.SetCharmInfo(hook.CharmInfo{ Name: "example", Summary: "An example charm", Description: "This charm does nothing", }) // Register any hooks and other charm logic here. deploy.MainFlags() flag.Parse() deploy.RunMain(r) // Could do other non-charm-related stuff here. For example, // a command could both act as a charm and as a locally runnable // server. }
Output:
Types ¶
type BuildCharmParams ¶
type BuildCharmParams struct { // Registry holds the hook registry that // represents the charm to be built. Registry *hook.Registry // CharmDir specifies the destination directory to write // the charm files to. This will be created by // BuildCharm if needed. CharmDir string // Source specifies that the source code is included // in the charm and the charm executable will be // built from that at hook execution time. // The caller is responsible for creating an // executable named "compile" in the charm's // root directory which should build the hook executable // to "bin/runhook". This can be done after // calling BuildCharm. Source bool // HookBinary holds the path to the hook // executable (mutually exclusive to Source). HookBinary string // NoCompress specifies that the binary should // not be compressed in the charm. NoCompress bool }
BuildCharmParams holds parameters for the BuildCharm function.