containerbuddy

package
v0.0.0-...-ca59479 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2016 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the version for this build, set at build time via LDFLAGS
	Version string
	// GitHash is the short-form commit hash of this build, set at build time
	GitHash string
)

Functions

func ApplyTemplate

func ApplyTemplate(config []byte) ([]byte, error)

ApplyTemplate creates and renders a template from the given config template

func GetIP

func GetIP(specList []string) (string, error)

GetIP determines the IP address of the container

func Main

func Main()

Main executes the containerbuddy CLI

Types

type BackendConfig

type BackendConfig struct {
	Name         string          `json:"name"`
	Poll         int             `json:"poll"` // time in seconds
	OnChangeExec json.RawMessage `json:"onChange"`
	Tag          string          `json:"tag,omitempty"`
	// contains filtered or unexported fields
}

BackendConfig represents a command to execute when another application changes

func (*BackendConfig) CheckForUpstreamChanges

func (b *BackendConfig) CheckForUpstreamChanges() bool

CheckForUpstreamChanges checks the service discovery endpoint for any changes in a dependent backend. Returns true when there has been a change.

func (*BackendConfig) OnChange

func (b *BackendConfig) OnChange() (int, error)

OnChange runs the backend's onChange command, returning the results

func (BackendConfig) PollTime

func (b BackendConfig) PollTime() int

PollTime returns the backend's poll time

type ByEtcdServiceID

type ByEtcdServiceID []EtcdServiceNode

ByEtcdServiceID implements the Sort interface because Go can't sort without it.

func (ByEtcdServiceID) Len

func (se ByEtcdServiceID) Len() int

func (ByEtcdServiceID) Less

func (se ByEtcdServiceID) Less(i, j int) bool

func (ByEtcdServiceID) Swap

func (se ByEtcdServiceID) Swap(i, j int)

type ByInterfaceThenIP

type ByInterfaceThenIP []interfaceIP

ByInterfaceThenIP implements the Sort with the following properties: 1. Sort interfaces alphabetically 2. Sort IPs by bytes (normalized to 16 byte form)

func (ByInterfaceThenIP) Len

func (se ByInterfaceThenIP) Len() int

func (ByInterfaceThenIP) Less

func (se ByInterfaceThenIP) Less(i, j int) bool

func (ByInterfaceThenIP) Swap

func (se ByInterfaceThenIP) Swap(i, j int)

type ByServiceID

type ByServiceID []*consul.ServiceEntry

ByServiceID implements the Sort interface because Go can't sort without it.

func (ByServiceID) Len

func (se ByServiceID) Len() int

func (ByServiceID) Less

func (se ByServiceID) Less(i, j int) bool

func (ByServiceID) Swap

func (se ByServiceID) Swap(i, j int)

type Config

type Config struct {
	Consul      string           `json:"consul,omitempty"`
	Etcd        json.RawMessage  `json:"etcd,omitempty"`
	LogConfig   *LogConfig       `json:"logging,omitempty"`
	OnStart     json.RawMessage  `json:"onStart,omitempty"`
	PreStart    json.RawMessage  `json:"preStart,omitempty"`
	PreStop     json.RawMessage  `json:"preStop,omitempty"`
	PostStop    json.RawMessage  `json:"postStop,omitempty"`
	StopTimeout int              `json:"stopTimeout"`
	Services    []*ServiceConfig `json:"services"`
	Backends    []*BackendConfig `json:"backends"`

	Command      *exec.Cmd
	QuitChannels []chan bool
	// contains filtered or unexported fields
}

Config is the top-level Containerbuddy Configuration

type ConfigTemplate

type ConfigTemplate struct {
	Template *template.Template
	Env      Environment
}

ConfigTemplate encapsulates a golang template and its associated environment variables.

func NewConfigTemplate

func NewConfigTemplate(config []byte) (*ConfigTemplate, error)

NewConfigTemplate creates a ConfigTemplate parsed from the configuration and the current environment variables

func (*ConfigTemplate) Execute

func (c *ConfigTemplate) Execute() ([]byte, error)

Execute renders the template

type Consul

type Consul struct{ consul.Client }

Consul is a service discovery backend for Hashicorp Consul

func NewConsulConfig

func NewConsulConfig(uri string) Consul

NewConsulConfig creates a new service discovery backend for Consul

func (Consul) CheckForUpstreamChanges

func (c Consul) CheckForUpstreamChanges(backend *BackendConfig) bool

CheckForUpstreamChanges runs the health check

func (Consul) Deregister

func (c Consul) Deregister(service *ServiceConfig)

Deregister removes the node from Consul.

func (Consul) MarkForMaintenance

func (c Consul) MarkForMaintenance(service *ServiceConfig)

MarkForMaintenance removes the node from Consul.

func (Consul) SendHeartbeat

func (c Consul) SendHeartbeat(service *ServiceConfig)

SendHeartbeat writes a TTL check status=ok to the consul store. If consul has never seen this service, we register the service and its TTL check.

type DefaultLogFormatter

type DefaultLogFormatter struct {
}

DefaultLogFormatter delegates formatting to standard go log package

func (*DefaultLogFormatter) Format

func (f *DefaultLogFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats the logrus entry by passing it to the "log" package

type DiscoveryService

type DiscoveryService interface {
	SendHeartbeat(*ServiceConfig)
	CheckForUpstreamChanges(*BackendConfig) bool
	MarkForMaintenance(*ServiceConfig)
	Deregister(*ServiceConfig)
}

DiscoveryService is an interface which all service discovery backends must implement

type Environment

type Environment map[string]string

Environment is a map of environment variables to their values

type Etcd

type Etcd struct {
	Client client.Client
	API    client.KeysAPI
	Prefix string
}

Etcd is a service discovery backend for CoreOS etcd

func NewEtcdConfig

func NewEtcdConfig(config json.RawMessage) Etcd

NewEtcdConfig creates a new service discovery backend for etcd

func (Etcd) CheckForUpstreamChanges

func (c Etcd) CheckForUpstreamChanges(backend *BackendConfig) bool

CheckForUpstreamChanges checks another etcd node for changes

func (Etcd) Deregister

func (c Etcd) Deregister(service *ServiceConfig)

Deregister removes this instance from the registry

func (Etcd) MarkForMaintenance

func (c Etcd) MarkForMaintenance(service *ServiceConfig)

MarkForMaintenance removes this instance from the registry

func (Etcd) SendHeartbeat

func (c Etcd) SendHeartbeat(service *ServiceConfig)

SendHeartbeat refreshes the TTL of this associated etcd node

type EtcdServiceNode

type EtcdServiceNode struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Address string   `json:"address"`
	Port    int      `json:"port"`
	Tags    []string `json:"tags,omitempty"`
}

EtcdServiceNode is an instance of a service

type LogConfig

type LogConfig struct {
	Level  string `json:"level"`
	Format string `json:"format,omitempty"`
	Output string `json:"output,omitempty"`
}

LogConfig configures the log levels

type Pollable

type Pollable interface {
	PollTime() int
}

Pollable is base abstraction for backends and services that support polling

type ServiceConfig

type ServiceConfig struct {
	ID              string
	Name            string          `json:"name"`
	Poll            int             `json:"poll"` // time in seconds
	HealthCheckExec json.RawMessage `json:"health"`
	Port            int             `json:"port"`
	TTL             int             `json:"ttl"`
	Interfaces      json.RawMessage `json:"interfaces"`
	Tags            []string        `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

ServiceConfig configures the service, discovery data, and health checks

func (*ServiceConfig) CheckHealth

func (s *ServiceConfig) CheckHealth() (int, error)

CheckHealth runs the service's health command, returning the results

func (*ServiceConfig) Deregister

func (s *ServiceConfig) Deregister()

Deregister will deregister this instance of the service

func (*ServiceConfig) MarkForMaintenance

func (s *ServiceConfig) MarkForMaintenance()

MarkForMaintenance marks this service for maintenance

func (ServiceConfig) PollTime

func (s ServiceConfig) PollTime() int

PollTime returns the service's poll time

func (*ServiceConfig) SendHeartbeat

func (s *ServiceConfig) SendHeartbeat()

SendHeartbeat sends a heartbeat for this service

Jump to

Keyboard shortcuts

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