prefab

package module
v0.0.0-...-c1a2256 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2017 License: MIT Imports: 10 Imported by: 1

README

Prefab

Quickly run docker containers for infrastructure when testing.

import "github.com/byrnedo/prefab"

// create and run a mysql container for this session
id, url := prefab.StartMysqlContainer()

// helper to wait for port to open
if err := prefab.WaitForMysql(url, 20 * time.Second); err != nil {
    panic(err)
}

// Connect using url :D

prefab.Remove(id)

Supports:

  • Mysql
  • Postgresql
  • Mongo
  • Nats

Although it's easy to roll your own.

Pull requests for new containers very welcome :)

Documentation

Index

Constants

View Source
const (
	MongoImage      = "mongo:3"
	MongoTmpfsImage = "byrnedo/mongo-tmpfs"
)
View Source
const (
	PostgresImage    = "postgres:latest"
	PostgresUser     = "postgres"
	PostgresPassword = "postgres"
	PostgresDatabase = ""
)
View Source
const (
	SftpImage    = "byrnedo/sftp:1"
	SftpUser     = "user"
	SftpPassword = "pass"
)
View Source
const (
	FtpImage = "mcreations/ftp:latest"
)
View Source
const (
	NatsImage = "nats:latest"
)
View Source
const (
	NatsStreamingImage = "nats-streaming:latest"
)

Variables

This section is empty.

Functions

func Remove

func Remove(id string) error

func RemoveByImage

func RemoveByImage(image string) error

func Running

func Running(image string) (string, error)

func StartCustom

func StartCustom(image string, command []string, portB map[gDoc.Port][]gDoc.PortBinding, envs []string, forcePull bool, privileged bool) (string, error)

func StartFtpContainer

func StartFtpContainer(optsFuncs ...ConfOverrideFunc) (id string, url string)

func StartMongoContainer

func StartMongoContainer(optsFuncs ...ConfOverrideFunc) (id string, url string)

func StartMongoTmpfsContainer

func StartMongoTmpfsContainer(optsFuncs ...ConfOverrideFunc) (id string, url string)

func StartMysqlContainer

func StartMysqlContainer(clientOpts ...ConfOverrideFunc) (id string, url string)

func StartMysqlTmpfsContainer

func StartMysqlTmpfsContainer(clientOpts ...ConfOverrideFunc) (id string, url string)

func StartNatsContainer

func StartNatsContainer(clientOpts ...ConfOverrideFunc) (id string, url string)

func StartNatsStreamingContainer

func StartNatsStreamingContainer(clientOpts ...ConfOverrideFunc) (id string, url string)

func StartPostgresContainer

func StartPostgresContainer(clientOpts ...ConfOverrideFunc) (id string, url string)

func StartSftpContainer

func StartSftpContainer(optsFuncs ...ConfOverrideFunc) (string, string)

func WaitForFtp

func WaitForFtp(url string, timeout time.Duration) error

func WaitForMongo

func WaitForMongo(url string, timeout time.Duration) error

func WaitForMysql

func WaitForMysql(url string, timeout time.Duration) error

func WaitForNats

func WaitForNats(url string, timeout time.Duration) error

func WaitForNatsStreaming

func WaitForNatsStreaming(url string, timeout time.Duration) error

func WaitForPort

func WaitForPort(addr string, timeout time.Duration) error

func WaitForPostgres

func WaitForPostgres(url string, timeout time.Duration) error

func WaitForSftp

func WaitForSftp(url string, timeout time.Duration) error

Types

type ConfOverrideFunc

type ConfOverrideFunc func(*SetupOpts)

type SetupOpts

type SetupOpts struct {
	Image         string
	Command       []string
	ExposedPort   int
	PublishedPort int
	Protocol      string
	HostIp        string
	ForcePull     bool
	Envs          []string
	Privileged    bool
	ExtraPorts    map[gDoc.Port][]gDoc.PortBinding
}

Jump to

Keyboard shortcuts

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