storage

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package storage is responsible for the persistent storage of state.

Sous state is stored in a file hierarchy like this:

/
    defs.yaml
    manifests/
        github.com/
            username/
                reponame/
                    dirname/
                        subdirname.yaml

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskStateManager

type DiskStateManager struct {
	BaseDir string
	Codec   *hy.Codec
}

DiskStateManager implements StateReader and StateWriter using disk storage as its back-end.

func NewDiskStateManager

func NewDiskStateManager(baseDir string) *DiskStateManager

NewDiskStateManager returns a new DiskStateManager configured to read and write from a filesystem tree containing YAML files.

func (*DiskStateManager) ReadState

func (dsm *DiskStateManager) ReadState() (*sous.State, error)

ReadState loads the entire intended state of the world from a dir.

func (*DiskStateManager) WriteState

func (dsm *DiskStateManager) WriteState(s *sous.State) error

WriteState records the entire intended state of the world to a dir.

type GitStateManager added in v0.0.3

type GitStateManager struct {
	sync.Mutex
	*DiskStateManager //can't just be a StateReader/Writer: needs dir
	// contains filtered or unexported fields
}

GitStateManager wraps a DiskStateManager and implements transactional writes to a Git remote. It also polls the Git remote for changes

Methods of GitStateManager are serialised, and thus safe for concurrent access. No two GitStateManagers should have DiskStateManagers using the same BaseDir.

func NewGitStateManager added in v0.0.3

func NewGitStateManager(dsm *DiskStateManager) *GitStateManager

NewGitStateManager creates a new GitStateManager wrapping the provided DiskStateManager.

func (*GitStateManager) ReadState added in v0.0.3

func (gsm *GitStateManager) ReadState() (*sous.State, error)

ReadState reads sous state from the local disk.

func (*GitStateManager) WriteState added in v0.0.3

func (gsm *GitStateManager) WriteState(s *sous.State) (err error)

WriteState writes sous state to disk, then attempts to push it to Remote. If the push fails, the state is reset and an error is returned.

Jump to

Keyboard shortcuts

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