directory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: MPL-2.0 Imports: 11 Imported by: 122

Documentation

Overview

The directory package includes the interface for the Otto Appfile directory service that stores data related to Appfiles.

The directory service is used to maintain forward and backward indexes of applications to projects, projects to infras, etc. This allows Otto to gain a global view of an Appfile when it is being used.

The existence of such a service allows Appfiles to not have to contain global information of a potentially complex project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestBackend

func TestBackend(t *testing.T, b Backend)

TestBackend is a public test helper that verifies a backend functions properly.

Types

type Backend

type Backend interface {
	// PutBlob writes binary data for a given project/infra/app.
	//
	// GetBlob reads that data back out.
	//
	// ListBlob lists the binary data stored.
	PutBlob(string, *BlobData) error
	GetBlob(string) (*BlobData, error)

	// PutInfra and GetInfra are the functions used to store and retrieve
	// data about infrastructures.
	PutInfra(*Infra) error
	GetInfra(*Infra) (*Infra, error)

	// PutDev stores the result of a dev.
	//
	// GetDev queries a dev. The result is returned. The parameter
	// must fill in the App, Infra, and InfraFlavor fields.
	PutDev(*Dev) error
	GetDev(*Dev) (*Dev, error)
	DeleteDev(*Dev) error

	// PutBuild stores the result of a build.
	//
	// GetBuild queries a build. The result is returned. The parameter
	// must fill in the App, Infra, and InfraFlavor fields.
	PutBuild(*Build) error
	GetBuild(*Build) (*Build, error)

	// PutDeploy stores the result of a build.
	//
	// GetDeploy queries a deploy. The result is returned. The parameter
	// must fill in the App, Infra, and InfraFlavor fields.
	PutDeploy(*Deploy) error
	GetDeploy(*Deploy) (*Deploy, error)
}

Backend is the interface for any directory service. It is effectively the protocol right now. In the future we may abstract this further to an official protocol if it proves to be necessary. Until then, it is a value add on top of the Appfile (but not part of that format) that Otto uses for global state.

type BlobData

type BlobData struct {
	// Key is the key for the blob data. This is populated on read and ignored
	// on any other operation.
	Key string

	// Data is the data for the blob data. When writing, this should be
	// the data to write. When reading, this is the data that is read.
	Data io.Reader
	// contains filtered or unexported fields
}

BlobData is the metadata and data associated with stored binary data. The fields and their usage varies depending on the operations, so please read the documentation for each field carefully.

func (*BlobData) Close

func (d *BlobData) Close() error

func (*BlobData) WriteToFile

func (d *BlobData) WriteToFile(path string) error

WriteToFile is a helper to write BlobData to a file. While this is a very easy thing to do, it is so common that we provide a function for doing so.

type BoltBackend

type BoltBackend struct {
	// Directory where data will be written. This directory will be
	// created if it doesn't exist.
	Dir string
}

BoltBackend is a Directory backend that stores data on local disk using BoltDB.

The primary use case for the BoltBackend is out-of-box experience for Otto and single developers. For team usage, BoltBackend is not recommended.

This backend also implements io.Closer and should be closed.

func (*BoltBackend) DeleteDev

func (b *BoltBackend) DeleteDev(dev *Dev) error

func (*BoltBackend) GetBlob

func (b *BoltBackend) GetBlob(k string) (*BlobData, error)

func (*BoltBackend) GetBuild

func (b *BoltBackend) GetBuild(build *Build) (*Build, error)

func (*BoltBackend) GetDeploy

func (b *BoltBackend) GetDeploy(deploy *Deploy) (*Deploy, error)

func (*BoltBackend) GetDev

func (b *BoltBackend) GetDev(dev *Dev) (*Dev, error)

func (*BoltBackend) GetInfra

func (b *BoltBackend) GetInfra(infra *Infra) (*Infra, error)

func (*BoltBackend) PutBlob

func (b *BoltBackend) PutBlob(k string, d *BlobData) error

func (*BoltBackend) PutBuild

func (b *BoltBackend) PutBuild(build *Build) error

func (*BoltBackend) PutDeploy

func (b *BoltBackend) PutDeploy(deploy *Deploy) error

func (*BoltBackend) PutDev

func (b *BoltBackend) PutDev(dev *Dev) error

func (*BoltBackend) PutInfra

func (b *BoltBackend) PutInfra(infra *Infra) error

type Build

type Build struct {
	// Lookup information for the Build. AppID, Infra, and InfraFlavor
	// are required.
	Lookup

	// Resulting artifact from the build
	Artifact map[string]string
}

Build represents a build of an App.

type Deploy

type Deploy struct {
	// Lookup information for the Deploy. AppID, Infra, and InfraFlavor
	// are required.
	Lookup

	// These fields should be set for Put and will be populated on Get
	State  DeployState       // State of the deploy
	Deploy map[string]string // Deploy information

	// Private fields. These are usually set on Get or Put.
	//
	// DO NOT MODIFY THESE.
	ID string
}

Deploy represents a deploy of an App.

func (*Deploy) IsDeployed

func (d *Deploy) IsDeployed() bool

IsDeployed reports if this deploy succeeded.

func (*Deploy) IsFailed

func (d *Deploy) IsFailed() bool

IsFailed reports if this deploy failed.

func (*Deploy) IsNew

func (d *Deploy) IsNew() bool

IsNew reports if this deploy is freshly created and not yet run

func (*Deploy) MarkFailed

func (d *Deploy) MarkFailed()

MarkFailed sets a deploy's state to failed

func (*Deploy) MarkGone

func (d *Deploy) MarkGone()

MarkGone resets a deploy's state to the "new" state

func (*Deploy) MarkSuccessful

func (d *Deploy) MarkSuccessful()

MarkSuccess sets a deploy's state to success

type DeployState

type DeployState byte

DeployState is used to track the state of a deploy.

This is required because a deploy is entered in the directory prior to the deploy actually happening so that we can always look up any binary blobs stored with a deploy even if it fails.

const (
	DeployStateInvalid DeployState = 0
	DeployStateNew     DeployState = iota
	DeployStateFail
	DeployStateSuccess
)

func (DeployState) String

func (i DeployState) String() string

type Dev

type Dev struct {
	// Lookup information for the Deploy. AppID is all that is required.
	Lookup

	// These fields should be set for Put and will be populated on Get
	State DevState // State of the dev environment

	// Private fields. These are usually set on Get or Put.
	//
	// DO NOT MODIFY THESE.
	ID string
}

Dev represents a development environment of an app.

func (*Dev) IsReady

func (d *Dev) IsReady() bool

func (*Dev) MarkReady

func (d *Dev) MarkReady()

type DevState

type DevState byte

DevState is used to track the state of an infrastructure.

This is required because the state of an infrastructure isn't binary. It can be not created at all, partially created, or fully created. We need to represent this in the directory.

const (
	DevStateInvalid DevState = 0
	DevStateNew     DevState = iota
	DevStateReady
)

func (DevState) String

func (i DevState) String() string

type Infra

type Infra struct {
	// Lookup information for the Infra. The only required field for
	// this is Infra. Optionally you may also specify Foundation to
	// get the infrastructure data for a foundation.
	Lookup

	// State is the state of this infrastructure. This is important since
	// it is possible for there to be a partial state. If we're in a
	// partial state then deploys and such can't go through yet.
	State InfraState

	// Outputs are the output data from the infrastructure step.
	// This is an opaque blob that is dependent on each infrastructure
	// type. Please refer to docs of a specific infra to learn more about
	// what values are here.
	Outputs map[string]string `json:"outputs"`

	// Private fields. These are usually set on Get or Put.
	//
	// DO NOT MODIFY THESE.
	ID string
}

Infra represents the data stored in the directory service about Infrastructures.

func (*Infra) IsPartial

func (i *Infra) IsPartial() bool

func (*Infra) IsReady

func (i *Infra) IsReady() bool

type InfraState

type InfraState byte

InfraState is used to track the state of an infrastructure.

This is required because the state of an infrastructure isn't binary. It can be not created at all, partially created, or fully created. We need to represent this in the directory.

const (
	InfraStateInvalid InfraState = 0
	InfraStatePartial InfraState = iota
	InfraStateReady
)

func (InfraState) String

func (i InfraState) String() string

type Lookup

type Lookup struct {
	AppID       string // AppID is the compiled Appfile ID for an App
	Infra       string // Infra is the infra type, i.e. "aws"
	InfraFlavor string // InfraFlavor is the flavor, i.e. "vpc-public-private"
	Foundation  string // Foundation is the name of he foundation, i.e. "consul"
}

Lookup has fields that are used for looking up data in the directory.

Note that not all fields are required for every lookup operation. Please see the documentation for the item you're trying to look up to learn more.

Jump to

Keyboard shortcuts

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