deployer

package
v0.0.0-...-1887219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleDeploy

type SimpleDeploy struct {
	Client interfaces.Client

	Debug bool
	Logf  func(format string, v ...interface{})
	// contains filtered or unexported fields
}

SimpleDeploy is a deploy struct that provides all of the needed deploy methods. It requires that you give it a Client interface so that it can perform its remote work. You must call Init before you use it, and Close when you are done.

func (*SimpleDeploy) AddDeploy

func (obj *SimpleDeploy) AddDeploy(ctx context.Context, id uint64, hash, pHash string, data *string) error

AddDeploy adds a new deploy. It takes an id and ensures it's sequential. If hash is not empty, then it will check that the pHash matches what the previous hash was, and also adds this new hash along side the id. This is useful to make sure you get a linear chain of git patches, and to avoid two contributors pushing conflicting deploys. This isn't git specific, and so any arbitrary string hash can be used. FIXME: prune old deploys from the store when they aren't needed anymore...

func (*SimpleDeploy) Close

func (obj *SimpleDeploy) Close() error

Close cleans up after using the deploy struct and waits for any ongoing watches to exit before it returns.

func (*SimpleDeploy) GetDeploy

func (obj *SimpleDeploy) GetDeploy(ctx context.Context, id uint64) (string, error)

GetDeploy returns the deploy with the specified id if it exists. If you input an id of 0, you'll get back an empty deploy without error. This is useful so that you can pass through this function easily. FIXME: implement this more efficiently so that it doesn't have to download *all* the old deploys from etcd!

func (*SimpleDeploy) GetDeploys

func (obj *SimpleDeploy) GetDeploys(ctx context.Context) (map[uint64]string, error)

GetDeploys gets all the available deploys.

func (*SimpleDeploy) GetMaxDeployID

func (obj *SimpleDeploy) GetMaxDeployID(ctx context.Context) (uint64, error)

GetMaxDeployID returns the maximum deploy id. If none are found, this returns zero. You must increment the returned value by one when you add a deploy. If two or more clients race for this deploy id, then the loser is not committed, and must repeat this GetMaxDeployID process until it succeeds with a commit!

func (*SimpleDeploy) Init

func (obj *SimpleDeploy) Init() error

Init validates the deploy structure and prepares it for first use.

func (*SimpleDeploy) WatchDeploy

func (obj *SimpleDeploy) WatchDeploy(ctx context.Context) (chan error, error)

WatchDeploy returns a channel which spits out events on new deploy activity. It closes the channel when it's done, and spits out errors when something goes wrong. If it can't start up, it errors immediately. The returned channel is buffered, so that a quick succession of events will get discarded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL