Documentation ¶
Overview ¶
Methods which interact directly with Consul. Should isolate the code for consul here.
Index ¶
Examples ¶
Constants ¶
View Source
const ( Undefined int = iota Bool Number String Array Object )
View Source
const (
Name = "jsonconsul"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JsonExport ¶
type JsonExport struct { // KV Path in Consul Prefix string // Place to put the config file ConfigFile string // If we are overwriting the ConfigFile should we timestamp // the versions so that there is a trail. Timestamp bool // Should we poll for consul changes. Watch bool // Should the output include the nodes in the included prefix? IncludePrefix bool // Parse the Values as Json JsonValues bool FlattenedKVs map[string]interface{} // contains filtered or unexported fields }
func (*JsonExport) GenerateJson ¶
func (c *JsonExport) GenerateJson() ([]byte, error)
func (*JsonExport) ParseFlags ¶
func (c *JsonExport) ParseFlags(args []string)
func (*JsonExport) Run ¶
func (c *JsonExport) Run() error
func (*JsonExport) RunWatcher ¶
func (c *JsonExport) RunWatcher()
func (*JsonExport) WriteFile ¶
func (c *JsonExport) WriteFile(newJson []byte) error
type JsonImport ¶
type JsonImport struct { // Prefix to load the config under. If empty then loads to the // root kv node. Prefix string // File containing the Json to be converted to KVs. Filename string FlattenedKVs map[string]interface{} }
func (*JsonImport) ParseFlags ¶
func (ji *JsonImport) ParseFlags(args []string)
func (*JsonImport) Run ¶
func (ji *JsonImport) Run() error
Example ¶
ji := &JsonImport{Filename: "example.json"} ji.Run() je := &JsonExport{Prefix: "foo", IncludePrefix: true, JsonValues: true} je.Run()
Output: {"foo":{"bar":"test","blah":"Test","bool":true,"do":"TEST","float":1.23,"loud":{"asd":{"bah":"test"}},"null":null}}
type JsonSet ¶
type JsonSet struct { // The Consul Key to set. Key string // The value that was passed by the command line. Value string // What we expect the value type to be. ExpectedType int // The actual Json Value that is going to be saved to Consul. JsonValue []byte }
func (*JsonSet) ParseFlags ¶
type Runner ¶ added in v0.4.0
type Runner struct { sync.RWMutex // Prefix is the KeyPrefixDependency associated with this Runner. Prefix *dep.StoreKeyPrefix // ErrCh and DoneCh are channels where errors and finish notifications occur. ErrCh chan error DoneCh chan struct{} // ExitCh is a channel for parent processes to read exit status values from // the child processes. ExitCh chan int // contains filtered or unexported fields }
func NewRunner ¶ added in v0.4.0
func NewRunner(config *JsonExport, once bool) (*Runner, error)
NewRunner accepts a JsonExport, and boolean value for once mode.
func (*Runner) Receive ¶ added in v0.4.0
func (r *Runner) Receive(d dep.Dependency, data interface{})
Receive accepts data from Consul and maps that data to the prefix.
func (*Runner) Run ¶ added in v0.4.0
func (r *Runner) Run()
Run executes and manages the child process with the correct environment. The current enviornment is also copied into the child process environment.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.