api

package
Version: v0.0.0-...-b90bf7d Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAppNameInvalid is the error returned when when trying to set invalid app name.
	ErrAppNameInvalid = errors.New("Name contains invalid characters. Alphanumeric only, no whitespace.")

	// ErrAppNotExist is the error returned when requested app ID or name doesn't exist.
	ErrAppNotExist = errors.New("App does not exist")

	// ErrAppNameTooLong is the error returned when trying to set too long app name.
	ErrAppNameTooLong = errors.New("App name too long. Max characters 30.")

	// AppNameMax is the maximum allowed length of an app name.
	AppNameMax = 30
)

Functions

This section is empty.

Types

type API

type API struct {
	Client *docker.Client
	Config *config.Config
	Logger *log.Logger
	DB     *sqlx.DB
}

API is an interface that binds together all parts of the host infrastructure.

func New

func New(client *docker.Client, conf *config.Config, logger *log.Logger) *API

New creates and returns a new host API.

func (*API) ConnectDB

func (a *API) ConnectDB() error

ConnectDB creates a new sqlx connection to running host database instance.

func (*API) GetAppRepo

func (a *API) GetAppRepo() *AppRepo

GetAppRepo creates and returns a new AppRepo instance.

func (*API) StartDB

func (a *API) StartDB(dev bool) error

StartDB boots up a host database instance.

func (*API) StopDB

func (a *API) StopDB() error

StopDB cleanly shuts down running host database instance.

type App

type App struct {
	ID        string     `db:"id"`
	Name      string     `db:"name"`
	CreatedAt *time.Time `db:"created_at"`
	UpdatedAt *time.Time `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

App represents the app in the database.

type AppRepo

type AppRepo struct {
	API *API
	DB  *sqlx.DB
}

AppRepo handles all interfacing between the host API and database.

func (*AppRepo) Create

func (r *AppRepo) Create(app *App) error

Create saves a new app into the database.

func (*AppRepo) Delete

func (r *AppRepo) Delete(name string) error

Delete deletes an app.

func (*AppRepo) Get

func (r *AppRepo) Get(id string) (*App, error)

Get finds an app by ID and returns it.

func (*AppRepo) GetByName

func (r *AppRepo) GetByName(name string) (*App, error)

GetByName finds an app by name and returns it.

func (*AppRepo) List

func (r *AppRepo) List() ([]App, error)

List returns all apps in the database.

func (*AppRepo) Update

func (r *AppRepo) Update(id string, data map[string]interface{}) (*App, error)

Update changes values of an existing app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL