Documentation ¶
Overview ¶
Package gapi defines the interface that graph API generators must meet.
Index ¶
- Constants
- Variables
- func CopyBytesToFs(fs engine.Fs, b []byte, dst string) error
- func CopyDirContentsToFs(fs engine.Fs, src, dst string) error
- func CopyDirToFs(fs engine.Fs, src, dst string) error
- func CopyDirToFsForceAll(fs engine.Fs, src, dst string) error
- func CopyFileToFs(fs engine.Fs, src, dst string) error
- func CopyStringToFs(fs engine.Fs, str, dst string) error
- func Register(name string, fn func() GAPI)
- type CliInfo
- type Data
- type Deploy
- type GAPI
- type GetInfo
- type GettableGAPI
- type Next
Constants ¶
const ( // CommandRun is the identifier for the "run" command. It is distinct // from the other commands, because it can run with any front-end. CommandRun = "run" // CommandDeploy is the identifier for the "deploy" command. CommandDeploy = "deploy" // CommandGet is the identifier for the "get" (download) command. CommandGet = "get" )
const Umask = 0666
Umask is the default to use when none has been specified. TODO: apparently using 0666 is equivalent to respecting the current umask
Variables ¶
var RegisteredGAPIs = make(map[string]func() GAPI) // must initialize this map
RegisteredGAPIs is a global map of all possible GAPIs which can be used. You should never touch this map directly. Use methods like Register instead.
Functions ¶
func CopyBytesToFs ¶
CopyBytesToFs copies a list of bytes to a dst path on fs.
func CopyDirContentsToFs ¶
CopyDirContentsToFs copies a dir contents from src path on the local fs to a dst path on fs.
func CopyDirToFs ¶
CopyDirToFs copies a dir from src path on the local fs to a dst path on fs. FIXME: I'm not sure this does the logical thing when the dst path is a dir. FIXME: We've got a workaround for this inside of the lang CLI GAPI.
func CopyDirToFsForceAll ¶
CopyDirToFsForceAll copies a dir from src path on the local fs to a dst path on fs, but it doesn't error when making a dir that already exists. It also uses `MkdirAll` to prevent some issues. FIXME: This is being added because of issues with CopyDirToFs. POSIX is hard.
func CopyFileToFs ¶
CopyFileToFs copies a file from src path on the local fs to a dst path on fs.
func CopyStringToFs ¶
CopyStringToFs copies a string to a dst path on fs.
Types ¶
type CliInfo ¶
type CliInfo struct { // CliContext is the struct that is used to transfer in user input. CliContext *cli.Context // Fs is the filesystem the Cli method should copy data into. It usually // copies *from* the local filesystem using standard io functionality. Fs engine.Fs Debug bool Logf func(format string, v ...interface{}) }
CliInfo is the set of input values passed into the Cli method so that the GAPI can decide if it wants to activate, and if it does, the initial handles it needs to use to do so.
type Data ¶
type Data struct { Program string // name of the originating program Hostname string // uuid for the host, required for GAPI World engine.World Noop bool NoStreamWatch bool Prefix string Debug bool Logf func(format string, v ...interface{}) }
Data is the set of input values passed into the GAPI structs via Init.
type Deploy ¶
type Deploy struct { ID uint64 Name string // lang, puppet, yaml, etc... //Sync bool // wait for everyone to close previous GAPI before switching Noop bool Sema int // sema override GAPI GAPI }
Deploy represents a deploy action, include the type of GAPI to deploy, the payload of that GAPI, and any deploy specific parameters that were chosen. TODO: add staged rollout functionality to this struct TODO: add proper authentication with gpg key signing
func NewDeployFromB64 ¶
NewDeployFromB64 decodes a deploy struct from a base64 encoded string.
type GAPI ¶
type GAPI interface { // CliFlags is passed a Command constant specifying which command it is // requesting the flags for. If an invalid or unsupported command is // passed in, simply return an empty list. Similarly, it is not required // to ever return any flags, and the GAPI may always return an empty // list. CliFlags(string) []cli.Flag // Cli is run on each GAPI to give it a chance to decide if it wants to // activate, and if it does, then it will return a deploy struct. During // this time, it uses the CliInfo struct as useful information to decide // what to do. Cli(*CliInfo) (*Deploy, error) // Init initializes the GAPI and passes in some useful data. Init(*Data) error // Graph returns the most recent pgraph. This is called by the engine on // every event from Next(). Graph() (*pgraph.Graph, error) // Next returns a stream of switch events. The engine will run Graph() // to build a new graph after every Next event. Next() chan Next // Close shuts down the GAPI. It asks the GAPI to close, and must cause // Next() to unblock even if is currently blocked and waiting to send a // new event. Close() error }
GAPI is a Graph API that represents incoming graphs and change streams. It is the frontend interface that needs to be implemented to use the engine.
type GetInfo ¶
type GetInfo struct { // CliContext is the struct that is used to transfer in user input. CliContext *cli.Context Noop bool Sema int Update bool Debug bool Logf func(format string, v ...interface{}) }
GetInfo is the set of input values passed into the Get method for it to run.
type GettableGAPI ¶
type GettableGAPI interface { GAPI // the base interface must be implemented // Get runs the get/download method. Get(*GetInfo) error }
GettableGAPI represents additional methods that need to be implemented in this GAPI so that it can be used with the `get` Command. The methods in this interface are called independently from the rest of the GAPI interface, and you must not rely on shared state from those methods. Logically, this should probably be named "Getable", however the correct modern word is "Gettable".
type Next ¶
type Next struct { // FIXME: the Fast pause parameter should eventually get replaced with a // "SwitchMethod" parameter or similar that instead lets the implementer // choose between fast pause, slow pause, and interrupt. Interrupt could // be a future extension to the Resource API that lets an Interrupt() be // called if we want to exit immediately from the CheckApply part of the // resource for some reason. For now we'll keep this simple with a bool. Fast bool // run a fast pause to switch? Exit bool // should we cause the program to exit? (specify err or not) Err error // if something goes wrong (use with or without exit!) }
Next describes the particular response the GAPI implementer wishes to emit.