Documentation ¶
Overview ¶
Package etcd is a library for performing common Etcd tasks.
Index ¶
- func CreateClient(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func FindSSHUser(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Get(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func IsRunning(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func MakeDir(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Set(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func StoreHostKeys(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func UpdateHostPort(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Watch(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- type DirCreator
- type Getter
- type GetterSetter
- type Setter
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateClient ¶
CreateClient creates a new Etcd client and prepares it for work.
Params:
- url (string): A server to connect to.
- retries (int): Number of times to retry a connection to the server
- retrySleep (time.Duration): How long to sleep between retries
Returns:
This puts an *etcd.Client into the context.
func FindSSHUser ¶
FindSSHUser finds an SSH user by public key.
Some parts of the system require that we know not only the SSH key, but also the name of the user. That information is stored in etcd.
Params:
- client (EtcdGetter)
- fingerprint (string): The fingerprint of the SSH key.
Returns: - username (string)
func Get ¶
Get performs an etcd Get operation.
Params:
- client (EtcdGetter): Etcd client
- path (string): The path/key to fetch
Returns:
- This puts an `etcd.Response` into the context, and returns an error if the client could not connect.
func IsRunning ¶
IsRunning checks to see if etcd is running.
It will test `count` times before giving up.
Params:
- client (EtcdGetter)
- count (int): Number of times to try before giving up.
Returns:
boolean true if etcd is listening.
func MakeDir ¶
MakeDir makes a directory in Etcd.
Params:
- client (EtcdDirCreator): Etcd client
- path (string): The name of the directory to create.
- ttl (uint64): Time to live.
Returns:
*etcd.Response
func Set ¶
Set sets a value in etcd.
Params:
- key (string): The key
- value (string): The value
- ttl (uint64): Time to live
- client (EtcdGetter): Client, usually an *etcd.Client.
Returns:
- *etcd.Result
func StoreHostKeys ¶
StoreHostKeys stores SSH hostkeys locally.
First it tries to fetch them from etcd. If the keys are not present there, it generates new ones and then puts them into etcd.
Params:
- client(EtcdGetterSetter)
- ciphers([]string): A list of ciphers to generate. Defaults are dsa, ecdsa, ed25519 and rsa.
- basepath (string): Base path in etcd (ETCD_PATH).
Returns:
func UpdateHostPort ¶
UpdateHostPort intermittently notifies etcd of the builder's address.
If `port` is specified, this will notify etcd at 10 second intervals that the builder is listening at $HOST:$PORT, setting the TTL to 20 seconds.
This will notify etcd as long as the local sshd is running.
Params:
- base (string): The base path to write the data: $base/host and $base/port.
- host (string): The hostname
- port (string): The port
- client (Setter): The client to use to write the data to etcd.
- sshPid (int): The PID for SSHD. If SSHD dies, this stops notifying.
func Watch ¶
Watch watches a given path, and executes a git check-repos for each event.
It starts the watcher and then returns. The watcher runs on its own goroutine. To stop the watching, send the returned channel a bool.
Params: - client (Watcher): An Etcd client. - path (string): The path to watch
Returns:
- chan bool: Send this a message to stop the watcher.
Types ¶
type DirCreator ¶
DirCreator describes etcd's CreateDir behavior.
Usually you will want to use go-etcd/etcd.Client to satisfy this.
type Getter ¶
Getter describes the Get behavior of an Etcd client.
Usually you will want to use go-etcd/etcd.Client to satisfy this.
We use an interface because it is more testable.
type GetterSetter ¶
GetterSetter performs get and set operations.