Ejemplo n.º 1
0
	API_TASKS        = API_VERSION + "/tasks"
	API_DEPLOYMENTS  = API_VERSION + "/deployments"
	API_GROUPS       = API_VERSION + "/groups"
	API_QUEUE        = API_VERSION + "/queue"
	API_INFO         = API_VERSION + "/info"
	API_LEADER       = API_VERSION + "/leader"
	API_PING         = "ping"
	API_LOGGING      = "logging"
	API_HELP         = "help"
	API_METRICS      = "metrics"

	DefaultTimeout = time.Duration(90) * time.Second
)

// Common package logger
var log = logger.GetLogger("depcon.marathon")

type CreateOptions struct {
	// if true will attempt to wait until the new application or group is running
	Wait bool
	// if true and an application/group already exists an update will be performed.
	// if false and an application/group exists an error will be returned
	Force bool
	// If true an error will be returned on params defined in the configuration file that
	// could not resolve to user input and environment variables
	ErrorOnMissingParams bool
	// Additional environment params - looks at this map for token substitution which takes
	// priority over matching environment variables
	EnvParams map[string]string
}
Ejemplo n.º 2
0
/*
 This is a semi-clone of original source found at : https://github.com/nparry/envterpolate and changed to adapt to use
 cases needed for depcon
*/
package envsubst

import (
	"bufio"
	"bytes"
	"github.com/gondor/depcon/pkg/logger"
	"io"
	"os"
	"unicode"
)

var log = logger.GetLogger("depcon")

type runeReader interface {
	ReadRune() (rune, int, error)
}

type runeWriter interface {
	WriteRune(rune) (int, error)
}

type state int

const (
	initial state = iota
	readingVarName
	readingBracedVarName
Ejemplo n.º 3
0
package compose

import (
	"github.com/gondor/depcon/pkg/logger"
)

const (
	DEFAULT_PROJECT string = "depcon_proj"
)

var log = logger.GetLogger("depcon.compose")

type Compose interface {
	Up(services ...string) error

	Kill(services ...string) error

	Logs(services ...string) error

	Delete(services ...string) error

	Build(services ...string) error

	Restart(services ...string) error

	Pull(services ...string) error

	Start(services ...string) error

	Stop(services ...string) error
Ejemplo n.º 4
0
package httpclient

import (
	"errors"
	"github.com/gondor/depcon/pkg/encoding"
	"github.com/gondor/depcon/pkg/logger"
	"io/ioutil"
	"net/http"
	"strings"
	"sync"
	"time"
)

var log = logger.GetLogger("client")

type Response struct {
	Status  int
	Content string
	Elapsed time.Duration
	Error   error
}

type Request struct {
	// Http Method type
	method Method
	// Complete URL including params
	url string
	// Post data
	data string
	// Expected data type
	result interface{}
Ejemplo n.º 5
0
package marathon

import (
	"github.com/gondor/depcon/pkg/logger"
	"github.com/gondor/depcon/utils"
	"time"
)

var logWait = logger.GetLogger("depcon.deploy.wait")

func (c *MarathonClient) WaitForApplication(id string, timeout time.Duration) error {
	t_now := time.Now()
	t_stop := t_now.Add(timeout)

	logWaitApplication(id)
	for {
		if time.Now().After(t_stop) {
			return ErrorTimeout
		}

		app, err := c.GetApplication(id)
		if err == nil {
			if app.DeploymentID == nil || len(app.DeploymentID) <= 0 {
				logWait.Info("Application deployment has completed for %s, elapsed time %s", id, utils.ElapsedStr(time.Since(t_now)))
				if app.HealthChecks != nil && len(app.HealthChecks) > 0 {
					err := c.WaitForApplicationHealthy(id, timeout)
					if err != nil {
						logWait.Error("Error waiting for application '%s' to become healthy: %s", id, err.Error())
					}
				} else {
					logWait.Warning("No health checks defined for '%s', skipping waiting for healthy state", id)