marathon

package module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

Build Status GoDoc Go Report Card Coverage Status

Go-Marathon

Go-marathon is a API library for working with Marathon. It currently supports

  • Application and group deployment
  • Helper filters for pulling the status, configuration and tasks
  • Multiple Endpoint support for HA deployments
  • Marathon Event Subscriptions and Event Streams
  • Pods

Note: the library is still under active development; users should expect frequent (possibly breaking) API changes for the time being.

It requires Go version 1.6 or higher.

Code Examples

There is also an examples directory in the source which shows hints and snippets of code of how to use it — which is probably the best place to start.

You can use examples/docker-compose.yml in order to start a test cluster.

Creating a client
import (
	marathon "github.com/gambol99/go-marathon"
)

marathonURL := "http://10.241.1.71:8080"
config := marathon.NewDefaultConfig()
config.URL = marathonURL
client, err := marathon.NewClient(config)
if err != nil {
	log.Fatalf("Failed to create a client for marathon, error: %s", err)
}

applications, err := client.Applications(nil)
...

Note, you can also specify multiple endpoint for Marathon (i.e. you have setup Marathon in HA mode and having multiple running)

marathonURL := "http://10.241.1.71:8080,10.241.1.72:8080,10.241.1.73:8080"

The first one specified will be used, if that goes offline the member is marked as "unavailable" and a background process will continue to ping the member until it's back online.

You can also pass a custom path to the URL, which is especially needed in case of DCOS:

marathonURL := "http://10.241.1.71:8080/cluster,10.241.1.72:8080/cluster,10.241.1.73:8080/cluster"

If you specify a DCOSToken in the configuration file but do not pass a custom URL path, /marathon will be used.

Customizing the HTTP Clients

HTTP clients with reasonable timeouts are used by default. It is possible to pass custom clients to the configuration though if the behavior should be customized (e.g., to bypass TLS verification, load root CAs, or change timeouts).

Two clients can be given independently of each other:

  • HTTPClient used only for (non-SSE) HTTP API requests. By default, an http.Client with 10 seconds timeout for the entire request is used.
  • HTTPSSEClient used only for SSE-based subscription requests. Note that HTTPSSEClient cannot have a response read timeout set as this breaks SSE communication; trying to do so will lead to an error during the SSE connection setup. By default, an http.Client with 5 seconds timeout for dial and TLS handshake, and 10 seconds timeout for response headers received is used.

If no HTTPSSEClient is given but an HTTPClient is, it will be used for SSE subscriptions as well (thereby overriding the default SSE HTTP client).

marathonURL := "http://10.241.1.71:8080"
config := marathon.NewDefaultConfig()
config.URL = marathonURL
config.HTTPClient = &http.Client{
    Timeout: (time.Duration(10) * time.Second),
    Transport: &http.Transport{
        Dial: (&net.Dialer{
            Timeout:   10 * time.Second,
            KeepAlive: 10 * time.Second,
        }).Dial,
        TLSClientConfig: &tls.Config{
            InsecureSkipVerify: true,
        },
    },
}
config.HTTPSSEClient = &http.Client{
    // Invalid to set Timeout as it contains timeout for reading a response body
    Transport: &http.Transport{
        Dial: (&net.Dialer{
            Timeout:   10 * time.Second,
            KeepAlive: 10 * time.Second,
        }).Dial,
        TLSClientConfig: &tls.Config{
            InsecureSkipVerify: true,
        },
    },
}
Listing the applications
applications, err := client.Applications(nil)
if err != nil {
	log.Fatalf("Failed to list applications: %s", err)
}

log.Printf("Found %d application(s) running", len(applications.Apps))
for _, application := range applications.Apps {
	log.Printf("Application: %s", application)
	appID := application.ID

	details, err := client.Application(appID)
	if err != nil {
		log.Fatalf("Failed to get application %s: %s", appID, err)
	}
	if details.Tasks != nil {
		for _, task := range details.Tasks {
			log.Printf("application %s has task: %s", appID, task)
		}
	}
}
Creating a new application
log.Printf("Deploying a new application")
application := marathon.NewDockerApplication().
  Name(applicationName).
  CPU(0.1).
  Memory(64).
  Storage(0.0).
  Count(2).
  AddArgs("/usr/sbin/apache2ctl", "-D", "FOREGROUND").
  AddEnv("NAME", "frontend_http").
  AddEnv("SERVICE_80_NAME", "test_http").
  CheckHTTP("/health", 10, 5)

application.
  Container.Docker.Container("quay.io/gambol99/apache-php:latest").
  Bridged().
  Expose(80).
  Expose(443)

if _, err := client.CreateApplication(application); err != nil {
	log.Fatalf("Failed to create application: %s, error: %s", application, err)
} else {
	log.Printf("Created the application: %s", application)
}

Note: Applications may also be defined by means of initializing a marathon.Application struct instance directly. However, go-marathon's DSL as shown above provides a more concise way to achieve the same.

Scaling application

Change the number of application instances to 4

log.Printf("Scale to 4 instances")
if err := client.ScaleApplicationInstances(application.ID, 4); err != nil {
	log.Fatalf("Failed to delete the application: %s, error: %s", application, err)
} else {
	client.WaitOnApplication(application.ID, 30 * time.Second)
	log.Printf("Successfully scaled the application")
}
Pods

Pods allow you to deploy groups of tasks as a unit. All tasks in a single instance of a pod share networking and storage. View the Marathon documentation for more details on this feature.

Examples of their usage can be seen in the examples/pods directory, and a smaller snippet is below.

// Initialize a single-container pod running nginx
pod := marathon.NewPod()

image := marathon.NewDockerPodContainerImage().SetID("nginx")

container := marathon.NewPodContainer().
	SetName("container", i).
	CPUs(0.1).
	Memory(128).
	SetImage(image)

pod.Name("mypod").AddContainer(container)

// Create it and wait for it to start up
pod, err := client.CreatePod(pod)
err = client.WaitOnPod(pod.ID, time.Minute*1)

// Scale it
pod.Count(5)
pod, err = client.UpdatePod(pod, true)

// Delete it
id, err := client.DeletePod(pod.ID, true)
Subscription & Events

Request to listen to events related to applications — namely status updates, health checks changes and failures. There are two different event transports controlled by EventsTransport setting with the following possible values: EventsTransportSSE and EventsTransportCallback (default value). See Event Stream and Event Subscriptions for details.

Event subscriptions can also be individually controlled with the Subscribe and Unsubscribe functions. See Controlling subscriptions for more details.

Event Stream

Only available in Marathon >= 0.9.0. Does not require any special configuration or prerequisites.

// Configure client
config := marathon.NewDefaultConfig()
config.URL = marathonURL
config.EventsTransport = marathon.EventsTransportSSE

client, err := marathon.NewClient(config)
if err != nil {
	log.Fatalf("Failed to create a client for marathon, error: %s", err)
}

// Register for events
events, err = client.AddEventsListener(marathon.EventIDApplications)
if err != nil {
	log.Fatalf("Failed to register for events, %s", err)
}

timer := time.After(60 * time.Second)
done := false

// Receive events from channel for 60 seconds
for {
	if done {
		break
	}
	select {
	case <-timer:
		log.Printf("Exiting the loop")
		done = true
	case event := <-events:
		log.Printf("Received event: %s", event)
	}
}

// Unsubscribe from Marathon events
client.RemoveEventsListener(events)
Event Subscriptions

Requires to start a built-in web server accessible by Marathon to connect and push events to. Consider the following additional settings:

  • EventsInterface — the interface we should be listening on for events. Default "eth0".
  • EventsPort — built-in web server port. Default 10001.
  • CallbackURL — custom callback URL. Default "".
// Configure client
config := marathon.NewDefaultConfig()
config.URL = marathonURL
config.EventsInterface = marathonInterface
config.EventsPort = marathonPort

client, err := marathon.NewClient(config)
if err != nil {
	log.Fatalf("Failed to create a client for marathon, error: %s", err)
}

// Register for events
events, err = client.AddEventsListener(marathon.EventIDApplications)
if err != nil {
	log.Fatalf("Failed to register for events, %s", err)
}

timer := time.After(60 * time.Second)
done := false

// Receive events from channel for 60 seconds
for {
	if done {
		break
	}
	select {
	case <-timer:
		log.Printf("Exiting the loop")
		done = true
	case event := <-events:
		log.Printf("Received event: %s", event)
	}
}

// Unsubscribe from Marathon events
client.RemoveEventsListener(events)

See events.go for a full list of event IDs.

Controlling subscriptions

If you simply want to (de)register event subscribers (i.e. without starting an internal web server) you can use the Subscribe and Unsubscribe methods.

// Configure client
config := marathon.NewDefaultConfig()
config.URL = marathonURL

client, err := marathon.NewClient(config)
if err != nil {
	log.Fatalf("Failed to create a client for marathon, error: %s", err)
}

// Register an event subscriber via a callback URL
callbackURL := "http://10.241.1.71:9494"
if err := client.Subscribe(callbackURL); err != nil {
	log.Fatalf("Unable to register the callbackURL [%s], error: %s", callbackURL, err)
}

// Deregister the same subscriber
if err := client.Unsubscribe(callbackURL); err != nil {
	log.Fatalf("Unable to deregister the callbackURL [%s], error: %s", callbackURL, err)
}

Contributing

See the contribution guidelines.

Development

Marathon Fake

go-marathon employs a fake Marathon implementation for testing purposes. It maintains a YML-encoded list of HTTP response messages which are returned upon a successful match based upon a number of attributes, the so-called message identifier:

  • HTTP URI (without the protocol and the hostname, e.g., /v2/apps)
  • HTTP method (e.g., GET)
  • response content (i.e., the message returned)
  • scope (see below)
Response Content

The response content can be provided in one of two forms:

  • static: A pure response message returned on every match, including repeated queries.
  • index: A list of response messages associated to a particular (indexed) sequence order. A message will be returned iff it matches and its zero-based index equals the current request count.

An example for a trivial static response content is

- uri: /v2/apps
  method: POST
  content: |
		{
		"app": {
		}
		}

which would be returned for every POST request targetting /v2/apps.

An indexed response content would look like:

- uri: /v2/apps
  method: POST
  contentSequence:
		- index: 1
		- content: |
			{
			"app": {
				"id": "foo"
			}
			}
		- index: 3
		- content: |
			{
			"app": {
				"id": "bar"
			}
			}

What this means is that the first POST request to /v2/apps would yield a 404, the second one the foo app, the third one 404 again, the fourth one bar, and every following request thereafter a 404 again. Indexed responses enable more flexible testing required by some use cases.

Trying to define both a static and indexed response content constitutes an error and leads to panic.

Scope

By default, all responses are defined globally: Every message can be queried by any request across all tests. This enables reusability and allows to keep the YML definition fairly short. For certain cases, however, it is desirable to define a set of responses that are delivered exclusively for a particular test. Scopes offer a means to do so by representing a concept similar to namespaces. Combined with indexed responses, they allow to return different responses for message identifiers already defined at the global level.

Scopes do not have a particular format -- they are just strings. A scope must be defined in two places: The message specification and the server configuration. They are pure strings without any particular structure. Given the messages specification

- uri: /v2/apps
  method: GET
	# Note: no scope defined.
  content: |
		{
		"app": {
			"id": "foo"
		}
		}
- uri: /v2/apps
  method: GET
	scope: v1.1.1  # This one does have a scope.
  contentSequence:
		- index: 1
		- content: |
			{
			"app": {
				"id": "bar"
			}
			}

and the tests

func TestFoo(t * testing.T) {
	endpoint := newFakeMarathonEndpoint(t, nil)  // No custom configs given.
	defer endpoint.Close()
	app, err := endpoint.Client.Applications(nil)
	// Do something with "foo"
}

func TestFoo(t * testing.T) {
	endpoint := newFakeMarathonEndpoint(t, &configContainer{
		server: &serverConfig{
			scope: "v1.1.1",		// Matches the message spec's scope.
		},
	})
	defer endpoint.Close()
	app, err := endpoint.Client.Applications(nil)
	// Do something with "bar"
}

The "foo" response can be used by all tests using the default fake endpoint (such as TestFoo), while the "bar" response is only visible by tests that explicitly set the scope to 1.1.1 (as TestBar does) and query the endpoint twice.

Documentation

Overview

Copyright 2019 The go-marathon Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Examples

Constants

View Source
const (
	// ErrCodeBadRequest specifies a 400 Bad Request error.
	ErrCodeBadRequest = iota
	// ErrCodeUnauthorized specifies a 401 Unauthorized error.
	ErrCodeUnauthorized
	// ErrCodeForbidden specifies a 403 Forbidden error.
	ErrCodeForbidden
	// ErrCodeNotFound specifies a 404 Not Found error.
	ErrCodeNotFound
	// ErrCodeDuplicateID specifies a PUT 409 Conflict error.
	ErrCodeDuplicateID
	// ErrCodeAppLocked specifies a POST 409 Conflict error.
	ErrCodeAppLocked
	// ErrCodeInvalidBean specifies a 422 UnprocessableEntity error.
	ErrCodeInvalidBean
	// ErrCodeServer specifies a 500+ Server error.
	ErrCodeServer
	// ErrCodeUnknown specifies an unknown error.
	ErrCodeUnknown
	// ErrCodeMethodNotAllowed specifies a 405 Method Not Allowed.
	ErrCodeMethodNotAllowed
)
View Source
const (
	// EventIDAPIRequest is the event listener ID for the corresponding event.
	EventIDAPIRequest = 1 << iota
	// EventIDStatusUpdate is the event listener ID for the corresponding event.
	EventIDStatusUpdate
	// EventIDFrameworkMessage is the event listener ID for the corresponding event.
	EventIDFrameworkMessage
	// EventIDSubscription is the event listener ID for the corresponding event.
	EventIDSubscription
	// EventIDUnsubscribed is the event listener ID for the corresponding event.
	EventIDUnsubscribed
	// EventIDStreamAttached is the event listener ID for the corresponding event.
	EventIDStreamAttached
	// EventIDStreamDetached is the event listener ID for the corresponding event.
	EventIDStreamDetached
	// EventIDAddHealthCheck is the event listener ID for the corresponding event.
	EventIDAddHealthCheck
	// EventIDRemoveHealthCheck is the event listener ID for the corresponding event.
	EventIDRemoveHealthCheck
	// EventIDFailedHealthCheck is the event listener ID for the corresponding event.
	EventIDFailedHealthCheck
	// EventIDChangedHealthCheck is the event listener ID for the corresponding event.
	EventIDChangedHealthCheck
	// EventIDGroupChangeSuccess is the event listener ID for the corresponding event.
	EventIDGroupChangeSuccess
	// EventIDGroupChangeFailed is the event listener ID for the corresponding event.
	EventIDGroupChangeFailed
	// EventIDDeploymentSuccess is the event listener ID for the corresponding event.
	EventIDDeploymentSuccess
	// EventIDDeploymentFailed is the event listener ID for the corresponding event.
	EventIDDeploymentFailed
	// EventIDDeploymentInfo is the event listener ID for the corresponding event.
	EventIDDeploymentInfo
	// EventIDDeploymentStepSuccess is the event listener ID for the corresponding event.
	EventIDDeploymentStepSuccess
	// EventIDDeploymentStepFailed is the event listener ID for the corresponding event.
	EventIDDeploymentStepFailed
	// EventIDAppTerminated is the event listener ID for the corresponding event.
	EventIDAppTerminated
	//EventIDApplications comprises all listener IDs for application events.
	EventIDApplications = EventIDStatusUpdate | EventIDChangedHealthCheck | EventIDFailedHealthCheck | EventIDAppTerminated
	//EventIDSubscriptions comprises all listener IDs for subscription events.
	EventIDSubscriptions = EventIDSubscription | EventIDUnsubscribed | EventIDStreamAttached | EventIDStreamDetached
)
View Source
const UnreachableStrategyAbsenceReasonDisabled = "disabled"

UnreachableStrategyAbsenceReasonDisabled signifies the reason of disabled unreachable strategy

Variables

View Source
var (
	// ErrMarathonDown is thrown when all the marathon endpoints are down
	ErrMarathonDown = errors.New("all the Marathon hosts are presently down")
	// ErrTimeoutError is thrown when the operation has timed out
	ErrTimeoutError = errors.New("the operation has timed out")
)
View Source
var (
	// ErrNoApplicationContainer is thrown when a container has been specified yet
	ErrNoApplicationContainer = errors.New("you have not specified a docker container yet")
)

Functions

func NewAPIError

func NewAPIError(code int, content []byte) error

NewAPIError creates a new APIError instance from the given response code and content.

Types

type APIError

type APIError struct {
	// ErrCode specifies the nature of the error.
	ErrCode int
	// contains filtered or unexported fields
}

APIError represents a generic API error.

func (*APIError) Error

func (e *APIError) Error() string

type AgentAttribute added in v0.8.0

type AgentAttribute struct {
	Name   string        `json:"name"`
	Text   *string       `json:"text,omitempty"`
	Scalar *float64      `json:"scalar,omitempty"`
	Ranges []NumberRange `json:"ranges,omitempty"`
	Set    []string      `json:"set,omitempty"`
}

AgentAttribute describes an attribute of an agent node

type Alias added in v0.8.0

type Alias Application

Alias aliases the Application struct so that it will be marshaled/unmarshaled automatically

type AllTasksOpts

type AllTasksOpts struct {
	Status string `url:"status,omitempty"`
}

AllTasksOpts contains a payload for AllTasks method

status:		Return only those tasks whose status matches this parameter.
		If not specified, all tasks are returned. Possible values: running, staging. Default: none.

type Application

type Application struct {
	ID          string        `json:"id,omitempty"`
	Cmd         *string       `json:"cmd,omitempty"`
	Args        *[]string     `json:"args,omitempty"`
	Constraints *[][]string   `json:"constraints,omitempty"`
	Container   *Container    `json:"container,omitempty"`
	CPUs        float64       `json:"cpus,omitempty"`
	GPUs        *float64      `json:"gpus,omitempty"`
	Disk        *float64      `json:"disk,omitempty"`
	Networks    *[]PodNetwork `json:"networks,omitempty"`

	// Contains non-secret environment variables. Secrets environment variables are part of the Secrets map.
	Env                        *map[string]string  `json:"-"`
	Executor                   *string             `json:"executor,omitempty"`
	HealthChecks               *[]HealthCheck      `json:"healthChecks,omitempty"`
	ReadinessChecks            *[]ReadinessCheck   `json:"readinessChecks,omitempty"`
	Instances                  *int                `json:"instances,omitempty"`
	Mem                        *float64            `json:"mem,omitempty"`
	Tasks                      []*Task             `json:"tasks,omitempty"`
	Ports                      []int               `json:"ports"`
	PortDefinitions            *[]PortDefinition   `json:"portDefinitions,omitempty"`
	RequirePorts               *bool               `json:"requirePorts,omitempty"`
	BackoffSeconds             *float64            `json:"backoffSeconds,omitempty"`
	BackoffFactor              *float64            `json:"backoffFactor,omitempty"`
	MaxLaunchDelaySeconds      *float64            `json:"maxLaunchDelaySeconds,omitempty"`
	TaskKillGracePeriodSeconds *float64            `json:"taskKillGracePeriodSeconds,omitempty"`
	Deployments                []map[string]string `json:"deployments,omitempty"`
	// Available when embedding readiness information through query parameter.
	ReadinessCheckResults *[]ReadinessCheckResult `json:"readinessCheckResults,omitempty"`
	Dependencies          []string                `json:"dependencies"`
	TasksRunning          int                     `json:"tasksRunning,omitempty"`
	TasksStaged           int                     `json:"tasksStaged,omitempty"`
	TasksHealthy          int                     `json:"tasksHealthy,omitempty"`
	TasksUnhealthy        int                     `json:"tasksUnhealthy,omitempty"`
	TaskStats             map[string]TaskStats    `json:"taskStats,omitempty"`
	User                  string                  `json:"user,omitempty"`
	UpgradeStrategy       *UpgradeStrategy        `json:"upgradeStrategy,omitempty"`
	UnreachableStrategy   *UnreachableStrategy    `json:"unreachableStrategy,omitempty"`
	KillSelection         string                  `json:"killSelection,omitempty"`
	Uris                  *[]string               `json:"uris,omitempty"`
	Version               string                  `json:"version,omitempty"`
	VersionInfo           *VersionInfo            `json:"versionInfo,omitempty"`
	Labels                *map[string]string      `json:"labels,omitempty"`
	AcceptedResourceRoles []string                `json:"acceptedResourceRoles,omitempty"`
	LastTaskFailure       *LastTaskFailure        `json:"lastTaskFailure,omitempty"`
	Fetch                 *[]Fetch                `json:"fetch,omitempty"`
	IPAddressPerTask      *IPAddressPerTask       `json:"ipAddress,omitempty"`
	Residency             *Residency              `json:"residency,omitempty"`
	Secrets               *map[string]Secret      `json:"-"`
	Role                  *string                 `json:"role,omitempty"`
}

Application is the definition for an application in marathon

func NewDockerApplication

func NewDockerApplication() *Application

NewDockerApplication creates a default docker application

func (*Application) AddArgs added in v0.1.0

func (r *Application) AddArgs(arguments ...string) *Application

AddArgs adds one or more arguments to the applications

arguments:	the argument(s) you are adding

func (*Application) AddConstraint added in v0.1.0

func (r *Application) AddConstraint(constraints ...string) *Application

AddConstraint adds a new constraint

constraints:	the constraint definition, one constraint per array element
Example
app := NewDockerApplication()

// add two constraints
app.AddConstraint("hostname", "UNIQUE").
	AddConstraint("rack_id", "CLUSTER", "rack-1")
Output:

func (*Application) AddEnv

func (r *Application) AddEnv(name, value string) *Application

AddEnv adds an environment variable to the application name: the name of the variable value: go figure, the value associated to the above

func (*Application) AddFetchURIs added in v0.1.0

func (r *Application) AddFetchURIs(fetchURIs ...Fetch) *Application

AddFetchURIs adds one or more fetch URIs to the application.

fetchURIs:	the fetch URI(s) to add.

func (*Application) AddHealthCheck added in v0.1.0

func (r *Application) AddHealthCheck(healthCheck HealthCheck) *Application

AddHealthCheck adds a health check

healthCheck the health check that should be added

func (*Application) AddLabel

func (r *Application) AddLabel(name, value string) *Application

AddLabel adds a label to the application

name:	the name of the label
value: value for this label

func (*Application) AddPortDefinition added in v0.2.0

func (r *Application) AddPortDefinition(portDefinition PortDefinition) *Application

AddPortDefinition adds a port definition. Port definitions are used to define ports that should be considered part of a resource. They are necessary when you are using HOST networking and no port mappings are specified.

func (*Application) AddReadinessCheck added in v0.8.0

func (r *Application) AddReadinessCheck(readinessCheck ReadinessCheck) *Application

AddReadinessCheck adds a readiness check.

func (*Application) AddSecret added in v0.8.0

func (r *Application) AddSecret(envVar, name, source string) *Application

AddSecret adds a secret declaration envVar: the name of the environment variable name: the name of the secret source: the source ID of the secret

func (*Application) AddUris added in v0.1.0

func (r *Application) AddUris(newUris ...string) *Application

AddUris adds one or more uris to the applications

arguments:	the uri(s) you are adding

func (*Application) AllTaskRunning

func (r *Application) AllTaskRunning() bool

AllTaskRunning checks to see if all the application tasks are running, i.e. the instances is equal to the number of running tasks

func (*Application) CPU

func (r *Application) CPU(cpu float64) *Application

CPU set the amount of CPU shares per instance which is assigned to the application

cpu:	the CPU shared (check Docker docs) per instance

func (*Application) CheckHTTP

func (r *Application) CheckHTTP(path string, port, interval int) (*Application, error)

CheckHTTP adds a HTTP check to an application

port: 		the port the check should be checking
interval:	the interval in seconds the check should be performed

func (*Application) CheckTCP

func (r *Application) CheckTCP(port, interval int) (*Application, error)

CheckTCP adds a TCP check to an application; note the port mapping must already exist, or an error will thrown

port: 		the port the check should, err, check
interval:	the interval in seconds the check should be performed

func (*Application) Command added in v0.1.0

func (r *Application) Command(cmd string) *Application

Command sets the cmd of the application

func (*Application) Count

func (r *Application) Count(count int) *Application

Count sets the number of instances of the application to run

count:	the number of instances to run

func (*Application) DependsOn

func (r *Application) DependsOn(names ...string) *Application

DependsOn adds one or more dependencies for this application. Note, if you want to wait for an application dependency to actually be UP, i.e. not just deployed, you need a health check on the dependant app.

names:	the application id(s) this application depends on

func (*Application) DeploymentIDs

func (r *Application) DeploymentIDs() []*DeploymentID

DeploymentIDs retrieves the application deployments IDs

func (*Application) EmptyArgs added in v0.1.0

func (r *Application) EmptyArgs() *Application

EmptyArgs explicitly empties arguments -- use this if you need to empty arguments of an application that already has arguments set (setting args to nil will keep the current value)

func (*Application) EmptyConstraints added in v0.1.0

func (r *Application) EmptyConstraints() *Application

EmptyConstraints explicitly empties constraints -- use this if you need to empty constraints of an application that already has constraints set (setting constraints to nil will keep the current value)

func (*Application) EmptyEnvs added in v0.1.0

func (r *Application) EmptyEnvs() *Application

EmptyEnvs explicitly empties the envs -- use this if you need to empty the environments of an application that already has environments set (setting env to nil will keep the current value)

func (*Application) EmptyFetchURIs added in v0.1.0

func (r *Application) EmptyFetchURIs() *Application

EmptyFetchURIs explicitly empties fetch URIs -- use this if you need to empty fetch URIs of an application that already has fetch URIs set. Setting fetch URIs to nil will keep the current value.

func (*Application) EmptyGPUs added in v0.8.0

func (r *Application) EmptyGPUs() *Application

EmptyGPUs explicitly empties GPUs -- use this if you need to empty gpus of an application that already has gpus set (setting port definitions to nil will keep the current value)

func (*Application) EmptyHealthChecks added in v0.1.0

func (r *Application) EmptyHealthChecks() *Application

EmptyHealthChecks explicitly empties health checks -- use this if you need to empty health checks of an application that already has health checks set (setting health checks to nil will keep the current value)

func (*Application) EmptyLabels added in v0.1.0

func (r *Application) EmptyLabels() *Application

EmptyLabels explicitly empties the labels -- use this if you need to empty the labels of an application that already has labels set (setting labels to nil will keep the current value)

func (*Application) EmptyNetworks added in v0.8.0

func (r *Application) EmptyNetworks() *Application

EmptyNetworks explicitly empties networks

func (*Application) EmptyPortDefinitions added in v0.2.0

func (r *Application) EmptyPortDefinitions() *Application

EmptyPortDefinitions explicitly empties port definitions -- use this if you need to empty port definitions of an application that already has port definitions set (setting port definitions to nil will keep the current value)

func (*Application) EmptyReadinessChecks added in v0.8.0

func (r *Application) EmptyReadinessChecks() *Application

EmptyReadinessChecks empties the readiness checks.

func (*Application) EmptyResidency added in v0.8.0

func (r *Application) EmptyResidency() *Application

EmptyResidency explicitly empties the residency -- use this if you need to empty the residency of an application that already has the residency set (setting it to nil will keep the current value).

func (*Application) EmptySecrets added in v0.8.0

func (r *Application) EmptySecrets() *Application

EmptySecrets explicitly empties the secrets -- use this if you need to empty the secrets of an application that already has secrets set (setting secrets to nil will keep the current value)

func (*Application) EmptyUnreachableStrategy added in v0.8.0

func (r *Application) EmptyUnreachableStrategy() *Application

EmptyUnreachableStrategy explicitly empties the unreachable strategy -- use this if you need to empty the unreachable strategy of an application that already has the unreachable strategy set (setting it to nil will keep the current value).

func (*Application) EmptyUpgradeStrategy added in v0.7.0

func (r *Application) EmptyUpgradeStrategy() *Application

EmptyUpgradeStrategy explicitly empties the upgrade strategy -- use this if you need to empty the upgrade strategy of an application that already has the upgrade strategy set (setting it to nil will keep the current value).

func (*Application) EmptyUris added in v0.1.0

func (r *Application) EmptyUris() *Application

EmptyUris explicitly empties uris -- use this if you need to empty uris of an application that already has uris set (setting uris to nil will keep the current value)

func (*Application) HasHealthChecks

func (r *Application) HasHealthChecks() bool

HasHealthChecks is a helper method, used to check if an application has health checks

func (*Application) MarshalJSON added in v0.8.0

func (app *Application) MarshalJSON() ([]byte, error)

MarshalJSON marshals the given Application as expected except for environment variables and secrets, which are marshaled from specialized structs. The environment variable piece of the secrets and other normal environment variables are combined and marshaled to the env field. The secrets and the related source are marshaled into the secrets field.

func (*Application) Memory

func (r *Application) Memory(memory float64) *Application

Memory sets he amount of memory the application can consume per instance

memory:	the amount of MB to assign

func (*Application) Name

func (r *Application) Name(id string) *Application

Name sets the name / ID of the application i.e. the identifier for this application

func (*Application) SetExecutor added in v0.1.0

func (r *Application) SetExecutor(executor string) *Application

SetExecutor sets the executor

func (*Application) SetGPUs added in v0.8.0

func (r *Application) SetGPUs(gpu float64) *Application

SetGPUs set the amount of GPU per instance which is assigned to the application

gpu:	the GPU (check MESOS docs) per instance

func (*Application) SetIPAddressPerTask added in v0.4.0

func (r *Application) SetIPAddressPerTask(ipAddressPerTask IPAddressPerTask) *Application

SetIPAddressPerTask defines that the application will have a IP address defines by a external agent. This configuration is not allowed to be used with Port or PortDefinitions. Thus, the implementation clears both.

func (*Application) SetNetwork added in v0.8.0

func (r *Application) SetNetwork(name string, mode PodNetworkMode) *Application

SetNetwork sets the networking mode

func (*Application) SetResidency added in v0.8.0

func (r *Application) SetResidency(whenLost TaskLostBehaviorType) *Application

SetResidency sets behavior for resident applications, an application is resident when it has local persistent volumes set

func (*Application) SetTaskKillGracePeriod added in v0.6.0

func (r *Application) SetTaskKillGracePeriod(seconds float64) *Application

SetTaskKillGracePeriod sets the number of seconds between escalating from SIGTERM to SIGKILL when signalling tasks to terminate. Using this grace period, tasks should perform orderly shut down immediately upon receiving SIGTERM.

seconds:	the number of seconds

func (*Application) SetUnreachableStrategy added in v0.8.0

func (r *Application) SetUnreachableStrategy(us UnreachableStrategy) *Application

SetUnreachableStrategy sets the unreachable strategy.

func (*Application) SetUpgradeStrategy added in v0.7.0

func (r *Application) SetUpgradeStrategy(us UpgradeStrategy) *Application

SetUpgradeStrategy sets the upgrade strategy.

func (*Application) Storage

func (r *Application) Storage(disk float64) *Application

Storage sets the amount of disk space the application is assigned, which for docker application I don't believe is relevant

disk:	the disk space in MB

func (*Application) String added in v0.1.0

func (r *Application) String() string

String returns the json representation of this application

func (*Application) UnmarshalJSON added in v0.8.0

func (app *Application) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the given Application JSON as expected except for environment variables and secrets. Environment varialbes are stored in the Env field. Secrets, including the environment variable part, are stored in the Secrets field.

type ApplicationVersion

type ApplicationVersion struct {
	Version string `json:"version"`
}

ApplicationVersion is the application version response from marathon

type ApplicationVersions

type ApplicationVersions struct {
	Versions []string `json:"versions"`
}

ApplicationVersions is a collection of application versions for a specific app in marathon

type Applications

type Applications struct {
	Apps []Application `json:"apps"`
}

Applications is a collection of applications

type Command

type Command struct {
	Value string `json:"value"`
}

Command is the command health check type

type CommandHealthCheck added in v0.8.0

type CommandHealthCheck struct {
	Command PodCommand `json:"command,omitempty"`
}

CommandHealthCheck describes a shell-based health check

func NewCommandHealthCheck added in v0.8.0

func NewCommandHealthCheck() *CommandHealthCheck

NewCommandHealthCheck creates an empty CommandHealthCheck

func (*CommandHealthCheck) SetCommand added in v0.8.0

SetCommand sets a CommandHealthCheck's underlying PodCommand

type Config

type Config struct {
	// URL is the url for marathon
	URL string
	// EventsTransport is the events transport: EventsTransportCallback or EventsTransportSSE
	EventsTransport EventsTransport
	// EventsPort is the event handler port
	EventsPort int
	// the interface we should be listening on for events
	EventsInterface string
	// HTTPBasicAuthUser is the http basic auth
	HTTPBasicAuthUser string
	// HTTPBasicPassword is the http basic password
	HTTPBasicPassword string
	// CallbackURL custom callback url
	CallbackURL string
	// DCOSToken for DCOS environment, This will override the Authorization header
	DCOSToken string
	// LogOutput the output for debug log messages
	LogOutput io.Writer
	// HTTPClient is the HTTP client
	HTTPClient *http.Client
	// HTTPSSEClient is the HTTP client used for SSE subscriptions, can't have client.Timeout set
	HTTPSSEClient *http.Client
	// wait time (in milliseconds) between repetitive requests to the API during polling
	PollingWaitTime time.Duration
}

Config holds the settings and options for the client

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig create a default client config

type Constraint added in v0.8.0

type Constraint struct {
	FieldName string `json:"fieldName"`
	Operator  string `json:"operator"`
	Value     string `json:"value,omitempty"`
}

Constraint describes the constraint for pod placement

type Container

type Container struct {
	Type         string         `json:"type,omitempty"`
	Docker       *Docker        `json:"docker,omitempty"`
	Volumes      *[]Volume      `json:"volumes,omitempty"`
	PortMappings *[]PortMapping `json:"portMappings,omitempty"`
}

Container is the definition for a container type in marathon

func NewDockerContainer

func NewDockerContainer() *Container

NewDockerContainer creates a default docker container for you

func (*Container) EmptyPortMappings added in v0.8.0

func (container *Container) EmptyPortMappings() *Container

EmptyPortMappings explicitly empties the port mappings -- use this if you need to empty port mappings of an application that already has port mappings set (setting port mappings to nil will keep the current value)

func (*Container) EmptyVolumes added in v0.1.0

func (container *Container) EmptyVolumes() *Container

EmptyVolumes explicitly empties the volumes -- use this if you need to empty volumes of an application that already has volumes set (setting volumes to nil will keep the current value)

func (*Container) Expose added in v0.8.0

func (container *Container) Expose(ports ...int) *Container

Expose sets the container to expose the following TCP ports

ports:			the TCP ports the container is exposing

func (*Container) ExposePort added in v0.8.0

func (container *Container) ExposePort(portMapping PortMapping) *Container

ExposePort exposes an port in the container

func (*Container) ExposeUDP added in v0.8.0

func (container *Container) ExposeUDP(ports ...int) *Container

ExposeUDP sets the container to expose the following UDP ports

ports:			the UDP ports the container is exposing

func (*Container) ServicePortIndex added in v0.8.0

func (container *Container) ServicePortIndex(port int) (int, error)

ServicePortIndex finds the service port index of the exposed port

port:			the port you are looking for

func (*Container) Volume

func (container *Container) Volume(hostPath, containerPath, mode string) *Container

Volume attachs a volume to the container

host_path:			the path on the docker host to map
container_path:		the path inside the container to map the host volume
mode:				the mode to map the container

type ContainerStatus added in v0.8.0

type ContainerStatus struct {
	Conditions  []*StatusCondition         `json:"conditions,omitempty"`
	ContainerID string                     `json:"containerId,omitempty"`
	Endpoints   []*PodEndpoint             `json:"endpoints,omitempty"`
	LastChanged string                     `json:"lastChanged,omitempty"`
	LastUpdated string                     `json:"lastUpdated,omitempty"`
	Message     string                     `json:"message,omitempty"`
	Name        string                     `json:"name,omitempty"`
	Resources   *Resources                 `json:"resources,omitempty"`
	Status      string                     `json:"status,omitempty"`
	StatusSince string                     `json:"statusSince,omitempty"`
	Termination *ContainerTerminationState `json:"termination,omitempty"`
}

ContainerStatus contains all status information for a container instance

type ContainerTerminationHistory added in v0.8.0

type ContainerTerminationHistory struct {
	ContainerID    string                     `json:"containerId,omitempty"`
	LastKnownState string                     `json:"lastKnownState,omitempty"`
	Termination    *ContainerTerminationState `json:"termination,omitempty"`
}

ContainerTerminationHistory is the termination history of a container in a pod

type ContainerTerminationState added in v0.8.0

type ContainerTerminationState struct {
	ExitCode int    `json:"exitCode,omitempty"`
	Message  string `json:"message,omitempty"`
}

ContainerTerminationState describes why a container terminated

type DeclinedOfferStep added in v0.8.0

type DeclinedOfferStep struct {
	Reason    string `json:"reason"`
	Declined  int32  `json:"declined"`
	Processed int32  `json:"processed"`
}

DeclinedOfferStep contains how often an offer was declined for a specific reason

type Delay added in v0.1.0

type Delay struct {
	Overdue         bool `json:"overdue"`
	TimeLeftSeconds int  `json:"timeLeftSeconds"`
}

Delay cotains the application postpone information

type DeleteAppOpts added in v0.1.0

type DeleteAppOpts struct {
	Force bool `url:"force,omitempty"`
}

DeleteAppOpts contains a payload for DeleteApplication method

force:		overrides a currently running deployment.

type DeleteGroupOpts added in v0.1.0

type DeleteGroupOpts struct {
	Force bool `url:"force,omitempty"`
}

DeleteGroupOpts contains a payload for DeleteGroup method

force:		overrides a currently running deployment.

type Deployment

type Deployment struct {
	ID             string              `json:"id"`
	Version        string              `json:"version"`
	CurrentStep    int                 `json:"currentStep"`
	TotalSteps     int                 `json:"totalSteps"`
	AffectedApps   []string            `json:"affectedApps"`
	AffectedPods   []string            `json:"affectedPods"`
	Steps          [][]*DeploymentStep `json:"-"`
	XXStepsRaw     json.RawMessage     `json:"steps"` // Holds raw steps JSON to unmarshal later
	CurrentActions []*DeploymentStep   `json:"currentActions"`
}

Deployment is a marathon deployment definition

type DeploymentID

type DeploymentID struct {
	DeploymentID string `json:"deploymentId"`
	Version      string `json:"version"`
}

DeploymentID is the identifier for a application deployment

type DeploymentPlan

type DeploymentPlan struct {
	ID       string         `json:"id"`
	Version  string         `json:"version"`
	Original *Group         `json:"original"`
	Target   *Group         `json:"target"`
	Steps    []*StepActions `json:"steps"`
}

DeploymentPlan is a collection of steps for application deployment

type DeploymentStep

type DeploymentStep struct {
	Action                string                  `json:"action"`
	App                   string                  `json:"app"`
	ReadinessCheckResults *[]ReadinessCheckResult `json:"readinessCheckResults,omitempty"`
}

DeploymentStep is a step in the application deployment plan

type Discovery added in v0.4.0

type Discovery struct {
	Ports *[]Port `json:"ports,omitempty"`
}

Discovery provides info about ports expose by IP-per-task functionality

func (*Discovery) AddPort added in v0.4.0

func (d *Discovery) AddPort(port Port) *Discovery

AddPort adds a port to the discovery info of a IP per task applicable

port: The discovery port

func (*Discovery) EmptyPorts added in v0.4.0

func (d *Discovery) EmptyPorts() *Discovery

EmptyPorts explicitly empties discovey port -- use this if you need to empty discovey port of an application that already has IP per task with discovey ports defined

type Docker

type Docker struct {
	ForcePullImage *bool          `json:"forcePullImage,omitempty"`
	Image          string         `json:"image,omitempty"`
	Network        string         `json:"network,omitempty"`
	Parameters     *[]Parameters  `json:"parameters,omitempty"`
	PortMappings   *[]PortMapping `json:"portMappings,omitempty"`
	Privileged     *bool          `json:"privileged,omitempty"`
	PullConfig     *PullConfig    `json:"pullConfig,omitempty"`
}

Docker is the docker definition from a marathon application

func (*Docker) AddParameter added in v0.1.0

func (docker *Docker) AddParameter(key string, value string) *Docker

AddParameter adds a parameter to the docker execution line when creating the container

key:			the name of the option to add
value:		the value of the option

func (*Docker) Bridged

func (docker *Docker) Bridged() *Docker

Bridged sets the networking mode to bridged

func (*Docker) Container

func (docker *Docker) Container(image string) *Docker

Container sets the image of the container

image:			the image name you are using

func (*Docker) EmptyParameters added in v0.1.0

func (docker *Docker) EmptyParameters() *Docker

EmptyParameters explicitly empties the parameters -- use this if you need to empty parameters of an application that already has parameters set (setting parameters to nil will keep the current value)

func (*Docker) EmptyPortMappings added in v0.1.0

func (docker *Docker) EmptyPortMappings() *Docker

EmptyPortMappings explicitly empties the port mappings -- use this if you need to empty port mappings of an application that already has port mappings set (setting port mappings to nil will keep the current value)

func (*Docker) Expose

func (docker *Docker) Expose(ports ...int) *Docker

Expose sets the container to expose the following TCP ports

ports:			the TCP ports the container is exposing

func (*Docker) ExposePort

func (docker *Docker) ExposePort(portMapping PortMapping) *Docker

ExposePort exposes an port in the container

func (*Docker) ExposeUDP

func (docker *Docker) ExposeUDP(ports ...int) *Docker

ExposeUDP sets the container to expose the following UDP ports

ports:			the UDP ports the container is exposing

func (*Docker) Host added in v0.1.0

func (docker *Docker) Host() *Docker

Host sets the networking mode to host

func (*Docker) ServicePortIndex

func (docker *Docker) ServicePortIndex(port int) (int, error)

ServicePortIndex finds the service port index of the exposed port

port:			the port you are looking for

func (*Docker) SetForcePullImage added in v0.1.0

func (docker *Docker) SetForcePullImage(forcePull bool) *Docker

SetForcePullImage sets whether the docker image should always be force pulled before starting an instance

forcePull:			true / false

func (*Docker) SetPrivileged added in v0.1.0

func (docker *Docker) SetPrivileged(priv bool) *Docker

SetPrivileged sets whether the docker image should be started with privilege turned on

priv:			true / false

func (*Docker) SetPullConfig added in v0.8.0

func (docker *Docker) SetPullConfig(pullConfig *PullConfig) *Docker

SetPullConfig adds *PullConfig to Docker

type EnabledUnreachableStrategy added in v0.8.0

type EnabledUnreachableStrategy struct {
	InactiveAfterSeconds *float64 `json:"inactiveAfterSeconds,omitempty"`
	ExpungeAfterSeconds  *float64 `json:"expungeAfterSeconds,omitempty"`
}

EnabledUnreachableStrategy covers parameters pertaining to present unreachable strategies.

type Event

type Event struct {
	ID    int
	Name  string
	Event interface{}
}

Event is the definition for a event in marathon

func GetEvent

func GetEvent(eventType string) (*Event, error)

GetEvent returns allocated empty event object which corresponds to provided event type

eventType:			the type of Marathon event

func (*Event) String

func (event *Event) String() string

type EventAPIRequest

type EventAPIRequest struct {
	EventType     string       `json:"eventType"`
	ClientIP      string       `json:"clientIp"`
	Timestamp     string       `json:"timestamp"`
	URI           string       `json:"uri"`
	AppDefinition *Application `json:"appDefinition"`
}

EventAPIRequest describes an 'api_post_event' event.

type EventAddHealthCheck

type EventAddHealthCheck struct {
	AppID       string `json:"appId"`
	EventType   string `json:"eventType"`
	HealthCheck struct {
		GracePeriodSeconds     float64 `json:"gracePeriodSeconds"`
		IntervalSeconds        float64 `json:"intervalSeconds"`
		MaxConsecutiveFailures float64 `json:"maxConsecutiveFailures"`
		Path                   string  `json:"path"`
		PortIndex              float64 `json:"portIndex"`
		Protocol               string  `json:"protocol"`
		TimeoutSeconds         float64 `json:"timeoutSeconds"`
	} `json:"healthCheck"`
	Timestamp string `json:"timestamp"`
}

EventAddHealthCheck describes an 'add_health_check_event' event.

type EventAppTerminated

type EventAppTerminated struct {
	EventType string `json:"eventType"`
	Timestamp string `json:"timestamp,omitempty"`
	AppID     string `json:"appId"`
}

EventAppTerminated describes an 'app_terminated_event' event.

type EventDeploymentFailed

type EventDeploymentFailed struct {
	ID        string `json:"id"`
	EventType string `json:"eventType"`
	Timestamp string `json:"timestamp"`
}

EventDeploymentFailed describes a 'deployment_failed' event.

type EventDeploymentInfo

type EventDeploymentInfo struct {
	EventType   string          `json:"eventType"`
	CurrentStep *StepActions    `json:"currentStep"`
	Timestamp   string          `json:"timestamp"`
	Plan        *DeploymentPlan `json:"plan"`
}

EventDeploymentInfo describes a 'deployment_info' event.

type EventDeploymentStepFailure

type EventDeploymentStepFailure struct {
	EventType   string          `json:"eventType"`
	CurrentStep *StepActions    `json:"currentStep"`
	Timestamp   string          `json:"timestamp"`
	Plan        *DeploymentPlan `json:"plan"`
}

EventDeploymentStepFailure describes a 'deployment_step_failure' event.

type EventDeploymentStepSuccess

type EventDeploymentStepSuccess struct {
	EventType   string          `json:"eventType"`
	CurrentStep *StepActions    `json:"currentStep"`
	Timestamp   string          `json:"timestamp"`
	Plan        *DeploymentPlan `json:"plan"`
}

EventDeploymentStepSuccess describes a 'deployment_step_success' event.

type EventDeploymentSuccess

type EventDeploymentSuccess struct {
	ID        string          `json:"id"`
	EventType string          `json:"eventType"`
	Timestamp string          `json:"timestamp"`
	Plan      *DeploymentPlan `json:"plan"`
}

EventDeploymentSuccess describes a 'deployment_success' event.

type EventFailedHealthCheck

type EventFailedHealthCheck struct {
	AppID       string `json:"appId"`
	EventType   string `json:"eventType"`
	HealthCheck struct {
		GracePeriodSeconds     float64 `json:"gracePeriodSeconds"`
		IntervalSeconds        float64 `json:"intervalSeconds"`
		MaxConsecutiveFailures float64 `json:"maxConsecutiveFailures"`
		Path                   string  `json:"path"`
		PortIndex              float64 `json:"portIndex"`
		Protocol               string  `json:"protocol"`
		TimeoutSeconds         float64 `json:"timeoutSeconds"`
	} `json:"healthCheck"`
	Timestamp string `json:"timestamp"`
}

EventFailedHealthCheck describes a 'failed_health_check_event' event.

type EventFrameworkMessage

type EventFrameworkMessage struct {
	EventType  string `json:"eventType"`
	ExecutorID string `json:"executorId"`
	Message    string `json:"message"`
	SlaveID    string `json:"slaveId"`
	Timestamp  string `json:"timestamp"`
}

EventFrameworkMessage describes a 'framework_message_event' event.

type EventGroupChangeFailed

type EventGroupChangeFailed struct {
	EventType string `json:"eventType"`
	GroupID   string `json:"groupId"`
	Timestamp string `json:"timestamp"`
	Version   string `json:"version"`
	Reason    string `json:"reason"`
}

EventGroupChangeFailed describes a 'group_change_failed' event.

type EventGroupChangeSuccess

type EventGroupChangeSuccess struct {
	EventType string `json:"eventType"`
	GroupID   string `json:"groupId"`
	Timestamp string `json:"timestamp"`
	Version   string `json:"version"`
}

EventGroupChangeSuccess describes a 'group_change_success' event.

type EventHealthCheckChanged

type EventHealthCheckChanged struct {
	EventType string `json:"eventType"`
	Timestamp string `json:"timestamp,omitempty"`
	AppID     string `json:"appId"`
	TaskID    string `json:"taskId"`
	Version   string `json:"version,omitempty"`
	Alive     bool   `json:"alive"`
}

EventHealthCheckChanged describes a 'health_status_changed_event' event.

type EventRemoveHealthCheck

type EventRemoveHealthCheck struct {
	AppID       string `json:"appId"`
	EventType   string `json:"eventType"`
	HealthCheck struct {
		GracePeriodSeconds     float64 `json:"gracePeriodSeconds"`
		IntervalSeconds        float64 `json:"intervalSeconds"`
		MaxConsecutiveFailures float64 `json:"maxConsecutiveFailures"`
		Path                   string  `json:"path"`
		PortIndex              float64 `json:"portIndex"`
		Protocol               string  `json:"protocol"`
		TimeoutSeconds         float64 `json:"timeoutSeconds"`
	} `json:"healthCheck"`
	Timestamp string `json:"timestamp"`
}

EventRemoveHealthCheck describes a 'remove_health_check_event' event.

type EventStatusUpdate

type EventStatusUpdate struct {
	EventType   string       `json:"eventType"`
	Timestamp   string       `json:"timestamp,omitempty"`
	SlaveID     string       `json:"slaveId,omitempty"`
	TaskID      string       `json:"taskId"`
	TaskStatus  string       `json:"taskStatus"`
	Message     string       `json:"message,omitempty"`
	AppID       string       `json:"appId"`
	Host        string       `json:"host"`
	Ports       []int        `json:"ports,omitempty"`
	IPAddresses []*IPAddress `json:"ipAddresses"`
	Version     string       `json:"version,omitempty"`
}

EventStatusUpdate describes a 'status_update_event' event.

type EventStreamAttached

type EventStreamAttached struct {
	RemoteAddress string `json:"remoteAddress"`
	EventType     string `json:"eventType"`
	Timestamp     string `json:"timestamp"`
}

EventStreamAttached describes an 'event_stream_attached' event.

type EventStreamDetached

type EventStreamDetached struct {
	RemoteAddress string `json:"remoteAddress"`
	EventType     string `json:"eventType"`
	Timestamp     string `json:"timestamp"`
}

EventStreamDetached describes an 'event_stream_detached' event.

type EventSubscription

type EventSubscription struct {
	CallbackURL string `json:"callbackUrl"`
	ClientIP    string `json:"clientIp"`
	EventType   string `json:"eventType"`
	Timestamp   string `json:"timestamp"`
}

EventSubscription describes a 'subscribe_event' event.

type EventType

type EventType struct {
	EventType string `json:"eventType"`
}

EventType is a wrapper for a marathon event

type EventUnsubscription

type EventUnsubscription struct {
	CallbackURL string `json:"callbackUrl"`
	ClientIP    string `json:"clientIp"`
	EventType   string `json:"eventType"`
	Timestamp   string `json:"timestamp"`
}

EventUnsubscription describes an 'unsubscribe_event' event.

type EventsChannel

type EventsChannel chan *Event

EventsChannel is a channel to receive events upon

type EventsChannelContext added in v0.3.0

type EventsChannelContext struct {
	// contains filtered or unexported fields
}

EventsChannelContext holds contextual data for an EventsChannel.

type EventsTransport

type EventsTransport int

EventsTransport describes which transport should be used to deliver Marathon events

const (
	// EventsTransportCallback activates callback events transport
	EventsTransportCallback EventsTransport = 1 << iota

	// EventsTransportSSE activates stream events transport
	EventsTransportSSE
)

type ExecutorResources added in v0.8.0

type ExecutorResources struct {
	Cpus float64 `json:"cpus,omitempty"`
	Mem  float64 `json:"mem,omitempty"`
	Disk float64 `json:"disk,omitempty"`
}

ExecutorResources are the resources supported by an executor (a task running a pod)

type ExternalVolume added in v0.4.0

type ExternalVolume struct {
	Name     string             `json:"name,omitempty"`
	Provider string             `json:"provider,omitempty"`
	Options  *map[string]string `json:"options,omitempty"`
}

ExternalVolume is an external volume definition

func (*ExternalVolume) AddOption added in v0.4.0

func (ev *ExternalVolume) AddOption(name, value string) *ExternalVolume

AddOption adds an option to an ExternalVolume

name:  the name of the option
value: value for the option

func (*ExternalVolume) EmptyOptions added in v0.4.0

func (ev *ExternalVolume) EmptyOptions() *ExternalVolume

EmptyOptions explicitly empties the options

type Fetch added in v0.1.0

type Fetch struct {
	URI        string `json:"uri"`
	Executable bool   `json:"executable"`
	Extract    bool   `json:"extract"`
	Cache      bool   `json:"cache"`
}

Fetch will download URI before task starts

type GetAppOpts added in v0.1.0

type GetAppOpts struct {
	Embed []string `url:"embed,omitempty"`
}

GetAppOpts contains a payload for Application method

embed:	Embeds nested resources that match the supplied path.
		You can specify this parameter multiple times with different values

type GetGroupOpts added in v0.1.0

type GetGroupOpts struct {
	Embed []string `url:"embed,omitempty"`
}

GetGroupOpts contains a payload for Group and Groups method

embed:		Embeds nested resources that match the supplied path.
			You can specify this parameter multiple times with different values

type Group

type Group struct {
	ID           string         `json:"id"`
	Apps         []*Application `json:"apps"`
	Dependencies []string       `json:"dependencies"`
	Groups       []*Group       `json:"groups"`
}

Group is a marathon application group

func NewApplicationGroup

func NewApplicationGroup(name string) *Group

NewApplicationGroup create a new application group

name:			the name of the group

func (*Group) App

func (r *Group) App(application *Application) *Group

App add a application to the group in question

application:	a pointer to the Application

func (*Group) Name

func (r *Group) Name(name string) *Group

Name sets the name of the group

name:	the name of the group

type Groups

type Groups struct {
	ID           string         `json:"id"`
	Apps         []*Application `json:"apps"`
	Dependencies []string       `json:"dependencies"`
	Groups       []*Group       `json:"groups"`
}

Groups is a collection of marathon application groups

type HTTPHealthCheck added in v0.8.0

type HTTPHealthCheck struct {
	Endpoint string `json:"endpoint,omitempty"`
	Path     string `json:"path,omitempty"`
	Scheme   string `json:"scheme,omitempty"`
}

HTTPHealthCheck describes an HTTP based health check

func NewHTTPHealthCheck added in v0.8.0

func NewHTTPHealthCheck() *HTTPHealthCheck

NewHTTPHealthCheck creates an empty HTTPHealthCheck

func (*HTTPHealthCheck) SetEndpoint added in v0.8.0

func (h *HTTPHealthCheck) SetEndpoint(endpoint string) *HTTPHealthCheck

SetEndpoint sets the name of the pod health check endpoint

func (*HTTPHealthCheck) SetPath added in v0.8.0

func (h *HTTPHealthCheck) SetPath(path string) *HTTPHealthCheck

SetPath sets the HTTP path of the pod health check endpoint

func (*HTTPHealthCheck) SetScheme added in v0.8.0

func (h *HTTPHealthCheck) SetScheme(scheme string) *HTTPHealthCheck

SetScheme sets the HTTP scheme of the pod health check endpoint

type HealthCheck

type HealthCheck struct {
	Command                *Command `json:"command,omitempty"`
	PortIndex              *int     `json:"portIndex,omitempty"`
	Port                   *int     `json:"port,omitempty"`
	Path                   *string  `json:"path,omitempty"`
	MaxConsecutiveFailures *int     `json:"maxConsecutiveFailures,omitempty"`
	Protocol               string   `json:"protocol,omitempty"`
	GracePeriodSeconds     int      `json:"gracePeriodSeconds,omitempty"`
	IntervalSeconds        int      `json:"intervalSeconds,omitempty"`
	TimeoutSeconds         int      `json:"timeoutSeconds,omitempty"`
	IgnoreHTTP1xx          *bool    `json:"ignoreHttp1xx,omitempty"`
}

HealthCheck is the definition for an application health check

func NewDefaultHealthCheck

func NewDefaultHealthCheck() *HealthCheck

NewDefaultHealthCheck creates a default application health check

func (*HealthCheck) SetCommand added in v0.1.0

func (h *HealthCheck) SetCommand(c Command) *HealthCheck

SetCommand sets the given command on the health check.

func (*HealthCheck) SetIgnoreHTTP1xx added in v0.8.0

func (h *HealthCheck) SetIgnoreHTTP1xx(ignore bool) *HealthCheck

SetIgnoreHTTP1xx sets ignore http 1xx on the health check.

func (*HealthCheck) SetMaxConsecutiveFailures added in v0.1.0

func (h *HealthCheck) SetMaxConsecutiveFailures(i int) *HealthCheck

SetMaxConsecutiveFailures sets the maximum consecutive failures on the health check.

func (*HealthCheck) SetPath added in v0.1.0

func (h *HealthCheck) SetPath(p string) *HealthCheck

SetPath sets the given path on the health check.

func (*HealthCheck) SetPort added in v0.1.0

func (h *HealthCheck) SetPort(i int) *HealthCheck

SetPort sets the given port on the health check.

func (*HealthCheck) SetPortIndex added in v0.1.0

func (h *HealthCheck) SetPortIndex(i int) *HealthCheck

SetPortIndex sets the given port index on the health check.

type HealthCheckResult

type HealthCheckResult struct {
	Alive               bool   `json:"alive"`
	ConsecutiveFailures int    `json:"consecutiveFailures"`
	FirstSuccess        string `json:"firstSuccess"`
	LastFailure         string `json:"lastFailure"`
	LastFailureCause    string `json:"lastFailureCause"`
	LastSuccess         string `json:"lastSuccess"`
	TaskID              string `json:"taskId"`
}

HealthCheckResult is the health check result

type IPAddress added in v0.1.0

type IPAddress struct {
	IPAddress string `json:"ipAddress"`
	Protocol  string `json:"protocol"`
}

IPAddress represents a task's IP address and protocol.

type IPAddressPerTask added in v0.4.0

type IPAddressPerTask struct {
	Groups      *[]string          `json:"groups,omitempty"`
	Labels      *map[string]string `json:"labels,omitempty"`
	Discovery   *Discovery         `json:"discovery,omitempty"`
	NetworkName string             `json:"networkName,omitempty"`
}

IPAddressPerTask is used by IP-per-task functionality https://mesosphere.github.io/marathon/docs/ip-per-task.html

func (*IPAddressPerTask) AddGroup added in v0.4.0

func (i *IPAddressPerTask) AddGroup(group string) *IPAddressPerTask

AddGroup adds a group to an IPAddressPerTask

group: The group name

func (*IPAddressPerTask) AddLabel added in v0.4.0

func (i *IPAddressPerTask) AddLabel(name, value string) *IPAddressPerTask

AddLabel adds a label to an IPAddressPerTask

 name: The label name
value: The label value

func (*IPAddressPerTask) EmptyGroups added in v0.4.0

func (i *IPAddressPerTask) EmptyGroups() *IPAddressPerTask

EmptyGroups explicitly empties groups -- use this if you need to empty groups of an application that already has IP per task with groups defined

func (*IPAddressPerTask) EmptyLabels added in v0.4.0

func (i *IPAddressPerTask) EmptyLabels() *IPAddressPerTask

EmptyLabels explicitly empties labels -- use this if you need to empty labels of an application that already has IP per task with labels defined

func (*IPAddressPerTask) SetDiscovery added in v0.4.0

func (i *IPAddressPerTask) SetDiscovery(discovery Discovery) *IPAddressPerTask

SetDiscovery define the discovery to an IPAddressPerTask

discovery: The discovery struct

type ImageType added in v0.8.0

type ImageType string

ImageType represents the image format type

const (
	// ImageTypeDocker is the docker format
	ImageTypeDocker ImageType = "DOCKER"

	// ImageTypeAppC is the appc format
	ImageTypeAppC ImageType = "APPC"
)

type Info

type Info struct {
	EventSubscriber struct {
		HTTPEndpoints []string `json:"http_endpoints"`
		Type          string   `json:"type"`
	} `json:"event_subscriber"`
	FrameworkID string `json:"frameworkId"`
	HTTPConfig  struct {
		AssetsPath interface{} `json:"assets_path"`
		HTTPPort   float64     `json:"http_port"`
		HTTPSPort  float64     `json:"https_port"`
	} `json:"http_config"`
	Leader         string `json:"leader"`
	MarathonConfig struct {
		Checkpoint                     bool    `json:"checkpoint"`
		Executor                       string  `json:"executor"`
		FailoverTimeout                float64 `json:"failover_timeout"`
		FrameworkName                  string  `json:"framework_name"`
		Ha                             bool    `json:"ha"`
		Hostname                       string  `json:"hostname"`
		LeaderProxyConnectionTimeoutMs float64 `json:"leader_proxy_connection_timeout_ms"`
		LeaderProxyReadTimeoutMs       float64 `json:"leader_proxy_read_timeout_ms"`
		LocalPortMax                   float64 `json:"local_port_max"`
		LocalPortMin                   float64 `json:"local_port_min"`
		Master                         string  `json:"master"`
		MesosLeaderUIURL               string  `json:"mesos_leader_ui_url"`
		WebUIURL                       string  `json:"webui_url"`
		MesosRole                      string  `json:"mesos_role"`
		MesosUser                      string  `json:"mesos_user"`
		ReconciliationInitialDelay     float64 `json:"reconciliation_initial_delay"`
		ReconciliationInterval         float64 `json:"reconciliation_interval"`
		TaskLaunchTimeout              float64 `json:"task_launch_timeout"`
		TaskReservationTimeout         float64 `json:"task_reservation_timeout"`
	} `json:"marathon_config"`
	Name            string `json:"name"`
	Version         string `json:"version"`
	ZookeeperConfig struct {
		Zk              string `json:"zk"`
		ZkFutureTimeout struct {
			Duration float64 `json:"duration"`
		} `json:"zk_future_timeout"`
		ZkHosts   string  `json:"zk_hosts"`
		ZkPath    string  `json:"zk_path"`
		ZkState   string  `json:"zk_state"`
		ZkTimeout float64 `json:"zk_timeout"`
	} `json:"zookeeper_config"`
}

Info is the detailed stats returned from marathon info

type InvalidEndpointError added in v0.5.0

type InvalidEndpointError struct {
	// contains filtered or unexported fields
}

InvalidEndpointError indicates a endpoint error in the marathon urls

func (*InvalidEndpointError) Error added in v0.5.0

func (e *InvalidEndpointError) Error() string

Error returns the string message

type Item added in v0.1.0

type Item struct {
	Count                  int                    `json:"count"`
	Delay                  Delay                  `json:"delay"`
	Application            *Application           `json:"app"`
	Pod                    *Pod                   `json:"pod"`
	Role                   string                 `json:"role"`
	Since                  string                 `json:"since"`
	ProcessedOffersSummary ProcessedOffersSummary `json:"processedOffersSummary"`
	LastUnusedOffers       []UnusedOffer          `json:"lastUnusedOffers,omitempty"`
}

Item is the definition of element in the queue

type KillApplicationTasksOpts

type KillApplicationTasksOpts struct {
	Host  string `url:"host,omitempty"`
	Scale bool   `url:"scale,omitempty"`
	Force bool   `url:"force,omitempty"`
}

KillApplicationTasksOpts contains a payload for KillApplicationTasks method

host:		kill only those tasks on a specific host (optional)
scale:		Scale the app down (i.e. decrement its instances setting by the number of tasks killed) after killing the specified tasks

type KillTaskOpts

type KillTaskOpts struct {
	Scale bool `url:"scale,omitempty"`
	Force bool `url:"force,omitempty"`
	Wipe  bool `url:"wipe,omitempty"`
}

KillTaskOpts contains a payload for task killing methods

scale:		Scale the app down

type LastTaskFailure

type LastTaskFailure struct {
	AppID     string `json:"appId,omitempty"`
	Host      string `json:"host,omitempty"`
	Message   string `json:"message,omitempty"`
	SlaveID   string `json:"slaveId,omitempty"`
	State     string `json:"state,omitempty"`
	TaskID    string `json:"taskId,omitempty"`
	Timestamp string `json:"timestamp,omitempty"`
	Version   string `json:"version,omitempty"`
}

LastTaskFailure provides details on the last error experienced by an application

type Marathon

type Marathon interface {
	ApiPost(path string, post, result interface{}) error

	// get a listing of the application ids
	ListApplications(url.Values) ([]string, error)
	// a list of application versions
	ApplicationVersions(name string) (*ApplicationVersions, error)
	// check a application version exists
	HasApplicationVersion(name, version string) (bool, error)
	// change an application to a different version
	SetApplicationVersion(name string, version *ApplicationVersion) (*DeploymentID, error)
	// check if an application is ok
	ApplicationOK(name string) (bool, error)
	// create an application in marathon
	CreateApplication(application *Application) (*Application, error)
	// delete an application
	DeleteApplication(name string, force bool) (*DeploymentID, error)
	// update an application in marathon
	UpdateApplication(application *Application, force bool) (*DeploymentID, error)
	// a list of deployments on a application
	ApplicationDeployments(name string) ([]*DeploymentID, error)
	// scale a application
	ScaleApplicationInstances(name string, instances int, force bool) (*DeploymentID, error)
	// restart an application
	RestartApplication(name string, force bool) (*DeploymentID, error)
	// get a list of applications from marathon
	Applications(url.Values) (*Applications, error)
	// get an application by name
	Application(name string) (*Application, error)
	// get an application by options
	ApplicationBy(name string, opts *GetAppOpts) (*Application, error)
	// get an application by name and version
	ApplicationByVersion(name, version string) (*Application, error)
	// wait of application
	WaitOnApplication(name string, timeout time.Duration) error

	// -- PODS ---
	// whether this version of Marathon supports pods
	SupportsPods() (bool, error)

	// get pod status
	PodStatus(name string) (*PodStatus, error)
	// get all pod statuses
	PodStatuses() ([]*PodStatus, error)

	// get pod
	Pod(name string) (*Pod, error)
	// get all pods
	Pods() ([]Pod, error)
	// create pod
	CreatePod(pod *Pod) (*Pod, error)
	// update pod
	UpdatePod(pod *Pod, force bool) (*Pod, error)
	// delete pod
	DeletePod(name string, force bool) (*DeploymentID, error)
	// wait on pod to be deployed
	WaitOnPod(name string, timeout time.Duration) error
	// check if a pod is running
	PodIsRunning(name string) bool

	// get versions of a pod
	PodVersions(name string) ([]string, error)
	// get pod by version
	PodByVersion(name, version string) (*Pod, error)

	// delete instances of a pod
	DeletePodInstances(name string, instances []string) ([]*PodInstance, error)
	// delete pod instance
	DeletePodInstance(name, instance string) (*PodInstance, error)

	// get a list of tasks for a specific application
	Tasks(application string) (*Tasks, error)
	// get a list of all tasks
	AllTasks(opts *AllTasksOpts) (*Tasks, error)
	// get the endpoints for a service on a application
	TaskEndpoints(name string, port int, healthCheck bool) ([]string, error)
	// kill all the tasks for any application
	KillApplicationTasks(applicationID string, opts *KillApplicationTasksOpts) (*Tasks, error)
	// kill a single task
	KillTask(taskID string, opts *KillTaskOpts) (*Task, error)
	// kill the given array of tasks
	KillTasks(taskIDs []string, opts *KillTaskOpts) error

	// list all the groups in the system
	Groups() (*Groups, error)
	// retrieve a specific group from marathon
	Group(name string) (*Group, error)
	// list all groups in marathon by options
	GroupsBy(opts *GetGroupOpts) (*Groups, error)
	// retrieve a specific group from marathon by options
	GroupBy(name string, opts *GetGroupOpts) (*Group, error)
	// create a group deployment
	CreateGroup(group *Group) error
	// delete a group
	DeleteGroup(name string, force bool) (*DeploymentID, error)
	// update a groups
	UpdateGroup(id string, group *Group, force bool) (*DeploymentID, error)
	// check if a group exists
	HasGroup(name string) (bool, error)
	// wait for an group to be deployed
	WaitOnGroup(name string, timeout time.Duration) error

	// get a list of the deployments
	Deployments() ([]*Deployment, error)
	// delete a deployment
	DeleteDeployment(id string, force bool) (*DeploymentID, error)
	// check to see if a deployment exists
	HasDeployment(id string) (bool, error)
	// wait of a deployment to finish
	WaitOnDeployment(id string, timeout time.Duration) error

	// a list of current subscriptions
	Subscriptions() (*Subscriptions, error)
	// add a events listener
	AddEventsListener(filter int) (EventsChannel, error)
	// remove a events listener
	RemoveEventsListener(channel EventsChannel)
	// Subscribe a callback URL
	Subscribe(string) error
	// Unsubscribe a callback URL
	Unsubscribe(string) error

	// --- QUEUE ---
	// get marathon launch queue
	Queue() (*Queue, error)
	// resets task launch delay of the specific application
	DeleteQueueDelay(appID string) error

	// get the marathon url
	GetMarathonURL() string
	// ping the marathon
	Ping() (bool, error)
	// grab the marathon server info
	Info() (*Info, error)
	// retrieve the leader info
	Leader() (string, error)
	// cause the current leader to abdicate
	AbdicateLeader() (string, error)
}

Marathon is the interface to the marathon API

func NewClient

func NewClient(config Config) (Marathon, error)

NewClient creates a new marathon client

config:			the configuration to use

type NumberRange added in v0.8.0

type NumberRange struct {
	Begin int64 `json:"begin"`
	End   int64 `json:"end"`
}

NumberRange is a range of numbers

type Offer added in v0.8.0

type Offer struct {
	ID         string           `json:"id"`
	Hostname   string           `json:"hostname"`
	AgentID    string           `json:"agentId"`
	Resources  []OfferResource  `json:"resources"`
	Attributes []AgentAttribute `json:"attributes"`
}

Offer describes a Mesos offer to a framework

type OfferResource added in v0.8.0

type OfferResource struct {
	Name   string        `json:"name"`
	Role   string        `json:"role"`
	Scalar *float64      `json:"scalar,omitempty"`
	Ranges []NumberRange `json:"ranges,omitempty"`
	Set    []string      `json:"set,omitempty"`
}

OfferResource describes a resource that is part of an offer

type Parameters

type Parameters struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

Parameters is the parameters to pass to the docker client when creating the container

type PersistentVolume added in v0.8.0

type PersistentVolume struct {
	Type        PersistentVolumeType `json:"type,omitempty"`
	Size        int                  `json:"size"`
	MaxSize     int                  `json:"maxSize,omitempty"`
	Constraints *[][]string          `json:"constraints,omitempty"`
}

PersistentVolume declares a Volume to be Persistent, and sets the size (in MiB) and optional type, max size (MiB) and constraints for the Volume.

func (*PersistentVolume) AddConstraint added in v0.8.0

func (p *PersistentVolume) AddConstraint(constraints ...string) *PersistentVolume

AddConstraint adds a new constraint

constraints:	the constraint definition, one constraint per array element

func (*PersistentVolume) EmptyConstraints added in v0.8.0

func (p *PersistentVolume) EmptyConstraints() *PersistentVolume

EmptyConstraints explicitly empties constraints -- use this if you need to empty constraints of an application that already has constraints set (setting constraints to nil will keep the current value)

func (*PersistentVolume) SetMaxSize added in v0.8.0

func (p *PersistentVolume) SetMaxSize(maxSize int) *PersistentVolume

SetMaxSize sets maximum size of an exclusive mount-disk resource to consider; does not apply to root or path disk resource types

maxSize:	size in MiB

func (*PersistentVolume) SetSize added in v0.8.0

func (p *PersistentVolume) SetSize(size int) *PersistentVolume

SetSize sets size of the persistent volume

size:	        size in MiB

func (*PersistentVolume) SetType added in v0.8.0

SetType sets the type of mesos disk resource to use

type:	       PersistentVolumeType enum

type PersistentVolumeType added in v0.8.0

type PersistentVolumeType string

PersistentVolumeType is the a persistent docker volume to be mounted

const (
	// PersistentVolumeTypeRoot is the root path of the persistent volume
	PersistentVolumeTypeRoot PersistentVolumeType = "root"
	// PersistentVolumeTypePath is the mount path of the persistent volume
	PersistentVolumeTypePath PersistentVolumeType = "path"
	// PersistentVolumeTypeMount is the mount type of the persistent volume
	PersistentVolumeTypeMount PersistentVolumeType = "mount"
)

type Pod added in v0.8.0

type Pod struct {
	ID      string            `json:"id,omitempty"`
	Labels  map[string]string `json:"labels,omitempty"`
	Version string            `json:"version,omitempty"`
	User    string            `json:"user,omitempty"`
	// Non-secret environment variables. Actual secrets are stored in Secrets
	// Magic happens at marshaling/unmarshaling to get them into the correct schema
	Env               map[string]string    `json:"-"`
	Secrets           map[string]Secret    `json:"-"`
	Containers        []*PodContainer      `json:"containers,omitempty"`
	Volumes           []*PodVolume         `json:"volumes,omitempty"`
	Networks          []*PodNetwork        `json:"networks,omitempty"`
	Scaling           *PodScalingPolicy    `json:"scaling,omitempty"`
	Scheduling        *PodSchedulingPolicy `json:"scheduling,omitempty"`
	ExecutorResources *ExecutorResources   `json:"executorResources,omitempty"`
	Role              *string              `json:"role,omitempty"`
}

Pod is the definition for an pod in marathon

func NewPod added in v0.8.0

func NewPod() *Pod

NewPod create an empty pod

func (*Pod) AddContainer added in v0.8.0

func (p *Pod) AddContainer(container *PodContainer) *Pod

AddContainer adds a container to a pod

func (*Pod) AddEnv added in v0.8.0

func (p *Pod) AddEnv(name, value string) *Pod

AddEnv adds an environment variable to a pod

func (*Pod) AddLabel added in v0.8.0

func (p *Pod) AddLabel(key, value string) *Pod

AddLabel adds a label to a pod

func (*Pod) AddNetwork added in v0.8.0

func (p *Pod) AddNetwork(net *PodNetwork) *Pod

AddNetwork adds a PodNetwork to a pod

func (*Pod) AddSecret added in v0.8.0

func (p *Pod) AddSecret(envVar, secretName, sourceName string) *Pod

AddSecret adds the secret to the pod

func (*Pod) AddVolume added in v0.8.0

func (p *Pod) AddVolume(vol *PodVolume) *Pod

AddVolume adds a volume to a pod

func (*Pod) Count added in v0.8.0

func (p *Pod) Count(count int) *Pod

Count sets the count of the pod

func (*Pod) EmptyEnvs added in v0.8.0

func (p *Pod) EmptyEnvs() *Pod

EmptyEnvs empties the environment variables for a pod

func (*Pod) EmptyLabels added in v0.8.0

func (p *Pod) EmptyLabels() *Pod

EmptyLabels empties the labels in a pod

func (*Pod) EmptySecrets added in v0.8.0

func (p *Pod) EmptySecrets() *Pod

EmptySecrets empties the secret sources in a pod

func (*Pod) ExtendEnv added in v0.8.0

func (p *Pod) ExtendEnv(env map[string]string) *Pod

ExtendEnv extends the environment with the new environment variables

func (*Pod) GetSecretSource added in v0.8.0

func (p *Pod) GetSecretSource(name string) (string, error)

GetSecretSource gets the source of the named secret

func (*Pod) MarshalJSON added in v0.8.0

func (p *Pod) MarshalJSON() ([]byte, error)

MarshalJSON marshals the given Pod as expected except for environment variables and secrets, which are marshaled from specialized structs. The environment variable piece of the secrets and other normal environment variables are combined and marshaled to the env field. The secrets and the related source are marshaled into the secrets field.

func (*Pod) Name added in v0.8.0

func (p *Pod) Name(id string) *Pod

Name sets the name / ID of the pod i.e. the identifier for this pod

func (*Pod) SetExecutorResources added in v0.8.0

func (p *Pod) SetExecutorResources(resources *ExecutorResources) *Pod

SetExecutorResources sets the resources for the pod executor

func (*Pod) SetLabels added in v0.8.0

func (p *Pod) SetLabels(labels map[string]string) *Pod

SetLabels sets the labels for a pod

func (*Pod) SetPodSchedulingPolicy added in v0.8.0

func (p *Pod) SetPodSchedulingPolicy(policy *PodSchedulingPolicy) *Pod

SetPodSchedulingPolicy sets the PodSchedulingPolicy of a pod

func (*Pod) SetUser added in v0.8.0

func (p *Pod) SetUser(user string) *Pod

SetUser sets the user to run the pod as

func (*Pod) UnmarshalJSON added in v0.8.0

func (p *Pod) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the given Pod JSON as expected except for environment variables and secrets. Environment variables are stored in the Env field. Secrets, including the environment variable part, are stored in the Secrets field.

type PodAgentInfo added in v0.8.0

type PodAgentInfo struct {
	Host       string   `json:"host"`
	AgentID    string   `json:"agentId"`
	Attributes []string `json:"attributes"`
}

PodAgentInfo contains info about the agent the instance is running on

type PodAlias added in v0.8.0

type PodAlias Pod

PodAlias aliases the Pod struct so that it will be marshaled/unmarshaled automatically

type PodArtifact added in v0.8.0

type PodArtifact struct {
	URI        string `json:"uri,omitempty"`
	Extract    bool   `json:"extract,omitempty"`
	Executable bool   `json:"executable,omitempty"`
	Cache      bool   `json:"cache,omitempty"`
	DestPath   string `json:"destPath,omitempty"`
}

PodArtifact describes how to obtain a generic artifact for a pod

type PodBackoff added in v0.8.0

type PodBackoff struct {
	Backoff        *float64 `json:"backoff,omitempty"`
	BackoffFactor  *float64 `json:"backoffFactor,omitempty"`
	MaxLaunchDelay *float64 `json:"maxLaunchDelay,omitempty"`
}

PodBackoff describes the backoff for re-run attempts of a pod

func NewPodBackoff added in v0.8.0

func NewPodBackoff() *PodBackoff

NewPodBackoff creates an empty PodBackoff

func (*PodBackoff) SetBackoff added in v0.8.0

func (p *PodBackoff) SetBackoff(backoffSeconds float64) *PodBackoff

SetBackoff sets the base backoff interval for failed pod launches, in seconds

func (*PodBackoff) SetBackoffFactor added in v0.8.0

func (p *PodBackoff) SetBackoffFactor(backoffFactor float64) *PodBackoff

SetBackoffFactor sets the backoff interval growth factor for failed pod launches

func (*PodBackoff) SetMaxLaunchDelay added in v0.8.0

func (p *PodBackoff) SetMaxLaunchDelay(maxLaunchDelaySeconds float64) *PodBackoff

SetMaxLaunchDelay sets the maximum backoff interval for failed pod launches, in seconds

type PodCommand added in v0.8.0

type PodCommand struct {
	Shell string `json:"shell,omitempty"`
}

PodCommand is the command to run as the entrypoint of the container

type PodContainer added in v0.8.0

type PodContainer struct {
	Name         string             `json:"name,omitempty"`
	Exec         *PodExec           `json:"exec,omitempty"`
	Resources    *Resources         `json:"resources,omitempty"`
	Endpoints    []*PodEndpoint     `json:"endpoints,omitempty"`
	Image        *PodContainerImage `json:"image,omitempty"`
	Env          map[string]string  `json:"-"`
	Secrets      map[string]Secret  `json:"-"`
	User         string             `json:"user,omitempty"`
	HealthCheck  *PodHealthCheck    `json:"healthCheck,omitempty"`
	VolumeMounts []*PodVolumeMount  `json:"volumeMounts,omitempty"`
	Artifacts    []*PodArtifact     `json:"artifacts,omitempty"`
	Labels       map[string]string  `json:"labels,omitempty"`
	Lifecycle    PodLifecycle       `json:"lifecycle,omitempty"`
}

PodContainer describes a container in a pod

func NewPodContainer added in v0.8.0

func NewPodContainer() *PodContainer

NewPodContainer creates an empty PodContainer

func (*PodContainer) AddArtifact added in v0.8.0

func (p *PodContainer) AddArtifact(artifact *PodArtifact) *PodContainer

AddArtifact appends an artifact to a pod container

func (*PodContainer) AddEndpoint added in v0.8.0

func (p *PodContainer) AddEndpoint(endpoint *PodEndpoint) *PodContainer

AddEndpoint appends an endpoint for a pod container

func (*PodContainer) AddEnv added in v0.8.0

func (p *PodContainer) AddEnv(name, value string) *PodContainer

AddEnv adds an environment variable for a pod container

func (*PodContainer) AddLabel added in v0.8.0

func (p *PodContainer) AddLabel(key, value string) *PodContainer

AddLabel adds a label to a pod container

func (*PodContainer) AddSecret added in v0.8.0

func (p *PodContainer) AddSecret(name, secretName string) *PodContainer

AddSecret adds a secret to the environment for a pod container

func (*PodContainer) AddVolumeMount added in v0.8.0

func (p *PodContainer) AddVolumeMount(mount *PodVolumeMount) *PodContainer

AddVolumeMount appends a volume mount to a pod container

func (*PodContainer) CPUs added in v0.8.0

func (p *PodContainer) CPUs(cpu float64) *PodContainer

CPUs sets the CPUs of a pod container

func (*PodContainer) EmptyEnvs added in v0.8.0

func (p *PodContainer) EmptyEnvs() *PodContainer

EmptyEnvs initialized env to empty

func (*PodContainer) ExtendEnv added in v0.8.0

func (p *PodContainer) ExtendEnv(env map[string]string) *PodContainer

ExtendEnv extends the environment for a pod container

func (*PodContainer) GPUs added in v0.8.0

func (p *PodContainer) GPUs(gpu int32) *PodContainer

GPUs sets the GPU requirements of a pod container

func (*PodContainer) MarshalJSON added in v0.8.0

func (p *PodContainer) MarshalJSON() ([]byte, error)

MarshalJSON marshals the given PodContainer as expected except for environment variables and secrets, which are marshaled from specialized structs. The environment variable piece of the secrets and other normal environment variables are combined and marshaled to the env field. The secrets and the related source are marshaled into the secrets field.

func (*PodContainer) Memory added in v0.8.0

func (p *PodContainer) Memory(memory float64) *PodContainer

Memory sets the memory of a pod container

func (*PodContainer) SetCommand added in v0.8.0

func (p *PodContainer) SetCommand(name string) *PodContainer

SetCommand sets the shell command of a pod container

func (*PodContainer) SetHealthCheck added in v0.8.0

func (p *PodContainer) SetHealthCheck(healthcheck *PodHealthCheck) *PodContainer

SetHealthCheck sets the health check of a pod container

func (*PodContainer) SetImage added in v0.8.0

func (p *PodContainer) SetImage(image *PodContainerImage) *PodContainer

SetImage sets the image of a pod container

func (*PodContainer) SetLifecycle added in v0.8.0

func (p *PodContainer) SetLifecycle(lifecycle PodLifecycle) *PodContainer

SetLifecycle sets the lifecycle of a pod container

func (*PodContainer) SetName added in v0.8.0

func (p *PodContainer) SetName(name string) *PodContainer

SetName sets the name of a pod container

func (*PodContainer) SetUser added in v0.8.0

func (p *PodContainer) SetUser(user string) *PodContainer

SetUser sets the user to run the pod as

func (*PodContainer) Storage added in v0.8.0

func (p *PodContainer) Storage(disk float64) *PodContainer

Storage sets the storage capacity of a pod container

func (*PodContainer) UnmarshalJSON added in v0.8.0

func (p *PodContainer) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the given PodContainer JSON as expected except for environment variables and secrets. Environment variables are stored in the Env field. Secrets, including the environment variable part, are stored in the Secrets field.

type PodContainerAlias added in v0.8.0

type PodContainerAlias PodContainer

PodContainerAlias aliases the PodContainer struct so that it will be marshaled/unmarshaled automatically

type PodContainerImage added in v0.8.0

type PodContainerImage struct {
	Kind      ImageType `json:"kind,omitempty"`
	ID        string    `json:"id,omitempty"`
	ForcePull bool      `json:"forcePull,omitempty"`
}

PodContainerImage describes how to retrieve the container image

func NewDockerPodContainerImage added in v0.8.0

func NewDockerPodContainerImage() *PodContainerImage

NewDockerPodContainerImage creates a docker PodContainerImage

func NewPodContainerImage added in v0.8.0

func NewPodContainerImage() *PodContainerImage

NewPodContainerImage creates an empty PodContainerImage

func (*PodContainerImage) SetID added in v0.8.0

SetID sets the ID of the image

func (*PodContainerImage) SetKind added in v0.8.0

SetKind sets the Kind of the image

type PodEndpoint added in v0.8.0

type PodEndpoint struct {
	Name          string            `json:"name,omitempty"`
	ContainerPort int               `json:"containerPort,omitempty"`
	HostPort      int               `json:"hostPort,omitempty"`
	Protocol      []string          `json:"protocol,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
}

PodEndpoint describes an endpoint for a pod's container

func NewPodEndpoint added in v0.8.0

func NewPodEndpoint() *PodEndpoint

NewPodEndpoint creates an empty PodEndpoint

func (*PodEndpoint) AddProtocol added in v0.8.0

func (e *PodEndpoint) AddProtocol(protocol string) *PodEndpoint

AddProtocol appends a protocol for a PodEndpoint

func (*PodEndpoint) Label added in v0.8.0

func (e *PodEndpoint) Label(key, value string) *PodEndpoint

Label sets a label for a PodEndpoint

func (*PodEndpoint) SetContainerPort added in v0.8.0

func (e *PodEndpoint) SetContainerPort(port int) *PodEndpoint

SetContainerPort sets the container port for a PodEndpoint

func (*PodEndpoint) SetHostPort added in v0.8.0

func (e *PodEndpoint) SetHostPort(port int) *PodEndpoint

SetHostPort sets the host port for a PodEndpoint

func (*PodEndpoint) SetName added in v0.8.0

func (e *PodEndpoint) SetName(name string) *PodEndpoint

SetName sets the name for a PodEndpoint

type PodExec added in v0.8.0

type PodExec struct {
	Command PodCommand `json:"command,omitempty"`
}

PodExec contains the PodCommand

type PodHealthCheck added in v0.8.0

type PodHealthCheck struct {
	HTTP                   *HTTPHealthCheck    `json:"http,omitempty"`
	TCP                    *TCPHealthCheck     `json:"tcp,omitempty"`
	Exec                   *CommandHealthCheck `json:"exec,omitempty"`
	GracePeriodSeconds     *int                `json:"gracePeriodSeconds,omitempty"`
	IntervalSeconds        *int                `json:"intervalSeconds,omitempty"`
	MaxConsecutiveFailures *int                `json:"maxConsecutiveFailures,omitempty"`
	TimeoutSeconds         *int                `json:"timeoutSeconds,omitempty"`
	DelaySeconds           *int                `json:"delaySeconds,omitempty"`
}

PodHealthCheck describes how to determine a pod's health

func NewPodHealthCheck added in v0.8.0

func NewPodHealthCheck() *PodHealthCheck

NewPodHealthCheck creates an empty PodHealthCheck

func (*PodHealthCheck) SetDelay added in v0.8.0

func (p *PodHealthCheck) SetDelay(delaySeconds int) *PodHealthCheck

SetDelay sets the length of time a pod will delay running health checks on initial launch, in seconds

func (*PodHealthCheck) SetExecHealthCheck added in v0.8.0

func (p *PodHealthCheck) SetExecHealthCheck(e *CommandHealthCheck) *PodHealthCheck

SetExecHealthCheck configures the pod's health check for a command. Note this will erase any configured HTTP/TCP health checks.

func (*PodHealthCheck) SetGracePeriod added in v0.8.0

func (p *PodHealthCheck) SetGracePeriod(gracePeriodSeconds int) *PodHealthCheck

SetGracePeriod sets the health check initial grace period, in seconds

func (*PodHealthCheck) SetHTTPHealthCheck added in v0.8.0

func (p *PodHealthCheck) SetHTTPHealthCheck(h *HTTPHealthCheck) *PodHealthCheck

SetHTTPHealthCheck configures the pod's health check for an HTTP endpoint. Note this will erase any configured TCP/Exec health checks.

func (*PodHealthCheck) SetInterval added in v0.8.0

func (p *PodHealthCheck) SetInterval(intervalSeconds int) *PodHealthCheck

SetInterval sets the health check polling interval, in seconds

func (*PodHealthCheck) SetMaxConsecutiveFailures added in v0.8.0

func (p *PodHealthCheck) SetMaxConsecutiveFailures(maxFailures int) *PodHealthCheck

SetMaxConsecutiveFailures sets the maximum consecutive failures on the health check

func (*PodHealthCheck) SetTCPHealthCheck added in v0.8.0

func (p *PodHealthCheck) SetTCPHealthCheck(t *TCPHealthCheck) *PodHealthCheck

SetTCPHealthCheck configures the pod's health check for a TCP endpoint. Note this will erase any configured HTTP/Exec health checks.

func (*PodHealthCheck) SetTimeout added in v0.8.0

func (p *PodHealthCheck) SetTimeout(timeoutSeconds int) *PodHealthCheck

SetTimeout sets the length of time the health check will await a result, in seconds

type PodInstance added in v0.8.0

type PodInstance struct {
	InstanceID          PodInstanceID              `json:"instanceId"`
	AgentInfo           PodAgentInfo               `json:"agentInfo"`
	TasksMap            map[string]PodTask         `json:"tasksMap"`
	RunSpecVersion      time.Time                  `json:"runSpecVersion"`
	State               PodInstanceStateHistory    `json:"state"`
	UnreachableStrategy EnabledUnreachableStrategy `json:"unreachableStrategy"`
}

PodInstance is the representation of an instance as returned by deleting an instance

type PodInstanceID added in v0.8.0

type PodInstanceID struct {
	ID string `json:"idString"`
}

PodInstanceID contains the instance ID

type PodInstanceState added in v0.8.0

type PodInstanceState string

PodInstanceState is the state of a specific pod instance

const (
	// PodInstanceStatePending is when an instance is pending scheduling
	PodInstanceStatePending PodInstanceState = "PENDING"

	// PodInstanceStateStaging is when an instance is staged to be scheduled
	PodInstanceStateStaging PodInstanceState = "STAGING"

	// PodInstanceStateStable is when an instance is stably running
	PodInstanceStateStable PodInstanceState = "STABLE"

	// PodInstanceStateDegraded is when an instance is degraded status
	PodInstanceStateDegraded PodInstanceState = "DEGRADED"

	// PodInstanceStateTerminal is when an instance is terminal
	PodInstanceStateTerminal PodInstanceState = "TERMINAL"
)

type PodInstanceStateHistory added in v0.8.0

type PodInstanceStateHistory struct {
	Condition   PodTaskCondition `json:"condition"`
	Since       time.Time        `json:"since"`
	ActiveSince time.Time        `json:"activeSince"`
}

PodInstanceStateHistory is the pod instance's state

type PodInstanceStatus added in v0.8.0

type PodInstanceStatus struct {
	AgentHostname string              `json:"agentHostname,omitempty"`
	Conditions    []*StatusCondition  `json:"conditions,omitempty"`
	Containers    []*ContainerStatus  `json:"containers,omitempty"`
	ID            string              `json:"id,omitempty"`
	LastChanged   string              `json:"lastChanged,omitempty"`
	LastUpdated   string              `json:"lastUpdated,omitempty"`
	Message       string              `json:"message,omitempty"`
	Networks      []*PodNetworkStatus `json:"networks,omitempty"`
	Resources     *Resources          `json:"resources,omitempty"`
	SpecReference string              `json:"specReference,omitempty"`
	Status        PodInstanceState    `json:"status,omitempty"`
	StatusSince   string              `json:"statusSince,omitempty"`
}

PodInstanceStatus is the status of a pod instance

type PodLifecycle added in v0.8.0

type PodLifecycle struct {
	KillGracePeriodSeconds *float64 `json:"killGracePeriodSeconds,omitempty"`
}

PodLifecycle describes the lifecycle of a pod

type PodNetwork added in v0.8.0

type PodNetwork struct {
	Name   string            `json:"name,omitempty"`
	Mode   PodNetworkMode    `json:"mode,omitempty"`
	Labels map[string]string `json:"labels,omitempty"`
}

PodNetwork contains network descriptors for a pod

func NewBridgePodNetwork added in v0.8.0

func NewBridgePodNetwork() *PodNetwork

NewBridgePodNetwork creates a PodNetwork for a container in bridge mode

func NewContainerPodNetwork added in v0.8.0

func NewContainerPodNetwork(name string) *PodNetwork

NewContainerPodNetwork creates a PodNetwork for a container

func NewHostPodNetwork added in v0.8.0

func NewHostPodNetwork() *PodNetwork

NewHostPodNetwork creates a PodNetwork for a container in host mode

func NewPodNetwork added in v0.8.0

func NewPodNetwork(name string) *PodNetwork

NewPodNetwork creates an empty PodNetwork

func (*PodNetwork) Label added in v0.8.0

func (n *PodNetwork) Label(key, value string) *PodNetwork

Label sets a label of a PodNetwork

func (*PodNetwork) SetMode added in v0.8.0

func (n *PodNetwork) SetMode(mode PodNetworkMode) *PodNetwork

SetMode sets the mode of a PodNetwork

func (*PodNetwork) SetName added in v0.8.0

func (n *PodNetwork) SetName(name string) *PodNetwork

SetName sets the name of a PodNetwork

type PodNetworkInfo added in v0.8.0

type PodNetworkInfo struct {
	HostName    string      `json:"hostName"`
	HostPorts   []int       `json:"hostPorts"`
	IPAddresses []IPAddress `json:"ipAddresses"`
}

PodNetworkInfo contains the network info for a task

type PodNetworkMode added in v0.8.0

type PodNetworkMode string

PodNetworkMode is the mode of a network descriptor

const (
	ContainerNetworkMode PodNetworkMode = "container"
	BridgeNetworkMode    PodNetworkMode = "container/bridge"
	HostNetworkMode      PodNetworkMode = "host"
)

type PodNetworkStatus added in v0.8.0

type PodNetworkStatus struct {
	Addresses []string `json:"addresses,omitempty"`
	Name      string   `json:"name,omitempty"`
}

PodNetworkStatus is the networks attached to a pod instance

type PodPlacement added in v0.8.0

type PodPlacement struct {
	Constraints           *[]Constraint `json:"constraints"`
	AcceptedResourceRoles []string      `json:"acceptedResourceRoles,omitempty"`
}

PodPlacement supports constraining which hosts a pod is placed on

func NewPodPlacement added in v0.8.0

func NewPodPlacement() *PodPlacement

NewPodPlacement creates an empty PodPlacement

func (*PodPlacement) AddConstraint added in v0.8.0

func (p *PodPlacement) AddConstraint(constraint Constraint) *PodPlacement

AddConstraint adds a new constraint

constraints:	the constraint definition, one constraint per array element

type PodScalingPolicy added in v0.8.0

type PodScalingPolicy struct {
	Kind         string `json:"kind"`
	Instances    int    `json:"instances"`
	MaxInstances int    `json:"maxInstances,omitempty"`
}

PodScalingPolicy is the scaling policy of the pod

type PodSchedulingPolicy added in v0.8.0

type PodSchedulingPolicy struct {
	Backoff             *PodBackoff          `json:"backoff,omitempty"`
	Upgrade             *PodUpgrade          `json:"upgrade,omitempty"`
	Placement           *PodPlacement        `json:"placement,omitempty"`
	UnreachableStrategy *UnreachableStrategy `json:"unreachableStrategy,omitempty"`
	KillSelection       string               `json:"killSelection,omitempty"`
}

PodSchedulingPolicy is the overarching pod scheduling policy

func NewPodSchedulingPolicy added in v0.8.0

func NewPodSchedulingPolicy() *PodSchedulingPolicy

NewPodSchedulingPolicy creates an empty PodSchedulingPolicy

func (*PodSchedulingPolicy) SetBackoff added in v0.8.0

func (p *PodSchedulingPolicy) SetBackoff(backoff *PodBackoff) *PodSchedulingPolicy

SetBackoff sets the pod's backoff settings

func (*PodSchedulingPolicy) SetKillSelection added in v0.8.0

func (p *PodSchedulingPolicy) SetKillSelection(killSelection string) *PodSchedulingPolicy

SetKillSelection sets the pod's kill selection criteria when terminating pod instances

func (*PodSchedulingPolicy) SetPlacement added in v0.8.0

func (p *PodSchedulingPolicy) SetPlacement(placement *PodPlacement) *PodSchedulingPolicy

SetPlacement sets the pod's placement settings

func (*PodSchedulingPolicy) SetUnreachableStrategy added in v0.8.0

func (p *PodSchedulingPolicy) SetUnreachableStrategy(strategy EnabledUnreachableStrategy) *PodSchedulingPolicy

SetUnreachableStrategy sets the pod's unreachable strategy for lost instances

func (*PodSchedulingPolicy) SetUnreachableStrategyDisabled added in v0.8.0

func (p *PodSchedulingPolicy) SetUnreachableStrategyDisabled() *PodSchedulingPolicy

SetUnreachableStrategyDisabled disables the pod's unreachable strategy

func (*PodSchedulingPolicy) SetUpgrade added in v0.8.0

func (p *PodSchedulingPolicy) SetUpgrade(upgrade *PodUpgrade) *PodSchedulingPolicy

SetUpgrade sets the pod's upgrade settings

type PodState added in v0.8.0

type PodState string

PodState defines the state of a pod

const (
	// PodStateDegraded is a degraded pod
	PodStateDegraded PodState = "DEGRADED"

	// PodStateStable is a stable pod
	PodStateStable PodState = "STABLE"

	// PodStateTerminal is a terminal pod
	PodStateTerminal PodState = "TERMINAL"
)

type PodStatus added in v0.8.0

type PodStatus struct {
	ID                 string                   `json:"id,omitempty"`
	Spec               *Pod                     `json:"spec,omitempty"`
	Status             PodState                 `json:"status,omitempty"`
	StatusSince        string                   `json:"statusSince,omitempty"`
	Message            string                   `json:"message,omitempty"`
	Instances          []*PodInstanceStatus     `json:"instances,omitempty"`
	TerminationHistory []*PodTerminationHistory `json:"terminationHistory,omitempty"`
	LastUpdated        string                   `json:"lastUpdated,omitempty"`
	LastChanged        string                   `json:"lastChanged,omitempty"`
}

PodStatus describes the pod status

type PodTask added in v0.8.0

type PodTask struct {
	TaskID         string        `json:"taskId"`
	RunSpecVersion time.Time     `json:"runSpecVersion"`
	Status         PodTaskStatus `json:"status"`
}

PodTask contains the info about the specific task within the instance

type PodTaskCondition added in v0.8.0

type PodTaskCondition struct {
	Str string `json:"str"`
}

PodTaskCondition contains a string representation of the condition

type PodTaskStatus added in v0.8.0

type PodTaskStatus struct {
	StagedAt    time.Time        `json:"stagedAt"`
	StartedAt   time.Time        `json:"startedAt"`
	MesosStatus string           `json:"mesosStatus"`
	Condition   PodTaskCondition `json:"condition"`
	NetworkInfo PodNetworkInfo   `json:"networkInfo"`
}

PodTaskStatus is the current status of the task

type PodTerminationHistory added in v0.8.0

type PodTerminationHistory struct {
	InstanceID   string                         `json:"instanceId,omitempty"`
	StartedAt    string                         `json:"startedAt,omitempty"`
	TerminatedAt string                         `json:"terminatedAt,omitempty"`
	Message      string                         `json:"message,omitempty"`
	Containers   []*ContainerTerminationHistory `json:"containers,omitempty"`
}

PodTerminationHistory is the termination history of the pod

type PodUpgrade added in v0.8.0

type PodUpgrade struct {
	MinimumHealthCapacity *float64 `json:"minimumHealthCapacity,omitempty"`
	MaximumOverCapacity   *float64 `json:"maximumOverCapacity,omitempty"`
}

PodUpgrade describes the policy for upgrading a pod in-place

func NewPodUpgrade added in v0.8.0

func NewPodUpgrade() *PodUpgrade

NewPodUpgrade creates a new PodUpgrade

func (*PodUpgrade) SetMaximumOverCapacity added in v0.8.0

func (p *PodUpgrade) SetMaximumOverCapacity(capacity float64) *PodUpgrade

SetMaximumOverCapacity sets the maximum amount of pod instances above the instance count, expressed as a fraction of instance count

func (*PodUpgrade) SetMinimumHealthCapacity added in v0.8.0

func (p *PodUpgrade) SetMinimumHealthCapacity(capacity float64) *PodUpgrade

SetMinimumHealthCapacity sets the minimum amount of pod instances for healthy operation, expressed as a fraction of instance count

type PodVolume added in v0.8.0

type PodVolume struct {
	Name       string            `json:"name,omitempty"`
	Host       string            `json:"host,omitempty"`
	Persistent *PersistentVolume `json:"persistent,omitempty"`
}

PodVolume describes a volume on the host

func NewPodVolume added in v0.8.0

func NewPodVolume(name, path string) *PodVolume

NewPodVolume creates a new PodVolume

func (*PodVolume) SetPersistentVolume added in v0.8.0

func (pv *PodVolume) SetPersistentVolume(p *PersistentVolume) *PodVolume

SetPersistentVolume sets the persistence settings of a PodVolume

type PodVolumeMount added in v0.8.0

type PodVolumeMount struct {
	Name      string `json:"name,omitempty"`
	MountPath string `json:"mountPath,omitempty"`
	ReadOnly  bool   `json:"readOnly,omitempty"`
}

PodVolumeMount describes how to mount a volume into a task

func NewPodVolumeMount added in v0.8.0

func NewPodVolumeMount(name, mount string) *PodVolumeMount

NewPodVolumeMount creates a new PodVolumeMount

type Port added in v0.4.0

type Port struct {
	Number   int    `json:"number,omitempty"`
	Name     string `json:"name,omitempty"`
	Protocol string `json:"protocol,omitempty"`
}

Port provides info about ports used by IP-per-task

type PortDefinition added in v0.2.0

type PortDefinition struct {
	Port     *int               `json:"port,omitempty"`
	Protocol string             `json:"protocol,omitempty"`
	Name     string             `json:"name,omitempty"`
	Labels   *map[string]string `json:"labels,omitempty"`
}

PortDefinition is a definition of a port that should be considered part of a resource. Port definitions are necessary when you are using HOST networking and no port mappings are specified.

func (*PortDefinition) AddLabel added in v0.2.0

func (p *PortDefinition) AddLabel(name, value string) *PortDefinition

AddLabel adds a label to the PortDefinition

name: the name of the label
value: value for this label

func (*PortDefinition) EmptyLabels added in v0.2.0

func (p *PortDefinition) EmptyLabels() *PortDefinition

EmptyLabels explicitly empties the labels -- use this if you need to empty the labels of a PortDefinition that already has labels set (setting labels to nill will keep the current value)

func (*PortDefinition) EmptyPort added in v0.8.0

func (p *PortDefinition) EmptyPort() *PortDefinition

EmptyPort sets the port to 0 for the PortDefinition

func (*PortDefinition) SetName added in v0.8.0

func (p *PortDefinition) SetName(name string) *PortDefinition

SetName sets the name for the PortDefinition name: the name of the PortDefinition

func (*PortDefinition) SetPort added in v0.2.0

func (p *PortDefinition) SetPort(port int) *PortDefinition

SetPort sets the given port for the PortDefinition

func (*PortDefinition) SetProtocol added in v0.8.0

func (p *PortDefinition) SetProtocol(protocol string) *PortDefinition

SetProtocol sets the protocol for the PortDefinition protocol: the protocol as a string

type PortMapping

type PortMapping struct {
	ContainerPort int                `json:"containerPort,omitempty"`
	HostPort      int                `json:"hostPort"`
	Labels        *map[string]string `json:"labels,omitempty"`
	Name          string             `json:"name,omitempty"`
	ServicePort   int                `json:"servicePort,omitempty"`
	Protocol      string             `json:"protocol,omitempty"`
	NetworkNames  *[]string          `json:"networkNames,omitempty"`
}

PortMapping is the portmapping structure between container and mesos

func (*PortMapping) AddLabel added in v0.2.0

func (p *PortMapping) AddLabel(name, value string) *PortMapping

AddLabel adds a label to a PortMapping

name:	the name of the label
value: value for this label

func (*PortMapping) AddNetwork added in v0.8.0

func (p *PortMapping) AddNetwork(name string) *PortMapping

AddNetwork adds a network name to a PortMapping

name:	the name of the network

func (*PortMapping) EmptyLabels added in v0.2.0

func (p *PortMapping) EmptyLabels() *PortMapping

EmptyLabels explicitly empties the labels -- use this if you need to empty the labels of a port mapping that already has labels set (setting labels to nil will keep the current value)

func (*PortMapping) EmptyNetworkNames added in v0.8.0

func (p *PortMapping) EmptyNetworkNames() *PortMapping

EmptyNetworkNames explicitly empties the network names -- use this if you need to empty the network names of a port mapping that already has network names set

type ProcessedOffersSummary added in v0.8.0

type ProcessedOffersSummary struct {
	ProcessedOffersCount       int32               `json:"processedOffersCount"`
	UnusedOffersCount          int32               `json:"unusedOffersCount"`
	LastUnusedOfferAt          *string             `json:"lastUnusedOfferAt,omitempty"`
	LastUsedOfferAt            *string             `json:"lastUsedOfferAt,omitempty"`
	RejectSummaryLastOffers    []DeclinedOfferStep `json:"rejectSummaryLastOffers,omitempty"`
	RejectSummaryLaunchAttempt []DeclinedOfferStep `json:"rejectSummaryLaunchAttempt,omitempty"`
}

ProcessedOffersSummary contains statistics for processed offers.

type PullConfig added in v0.8.0

type PullConfig struct {
	Secret string `json:"secret,omitempty"`
}

PullConfig specifies a secret for authentication with a private Docker registry

func NewPullConfig added in v0.8.0

func NewPullConfig(secret string) *PullConfig

NewPullConfig creats a *PullConfig based on a given secret

type Queue added in v0.1.0

type Queue struct {
	Items []Item `json:"queue"`
}

Queue is the definition of marathon queue

type ReadinessCheck added in v0.8.0

type ReadinessCheck struct {
	Name                    *string `json:"name,omitempty"`
	Protocol                string  `json:"protocol,omitempty"`
	Path                    string  `json:"path,omitempty"`
	PortName                string  `json:"portName,omitempty"`
	IntervalSeconds         int     `json:"intervalSeconds,omitempty"`
	TimeoutSeconds          int     `json:"timeoutSeconds,omitempty"`
	HTTPStatusCodesForReady *[]int  `json:"httpStatusCodesForReady,omitempty"`
	PreserveLastResponse    *bool   `json:"preserveLastResponse,omitempty"`
}

ReadinessCheck represents a readiness check.

func (*ReadinessCheck) SetHTTPStatusCodesForReady added in v0.8.0

func (rc *ReadinessCheck) SetHTTPStatusCodesForReady(codes []int) *ReadinessCheck

SetHTTPStatusCodesForReady sets the HTTP status codes for ready on the readiness check.

func (*ReadinessCheck) SetInterval added in v0.8.0

func (rc *ReadinessCheck) SetInterval(interval time.Duration) *ReadinessCheck

SetInterval sets the interval on the readiness check.

func (*ReadinessCheck) SetName added in v0.8.0

func (rc *ReadinessCheck) SetName(name string) *ReadinessCheck

SetName sets the name on the readiness check.

func (*ReadinessCheck) SetPath added in v0.8.0

func (rc *ReadinessCheck) SetPath(p string) *ReadinessCheck

SetPath sets the path on the readiness check.

func (*ReadinessCheck) SetPortName added in v0.8.0

func (rc *ReadinessCheck) SetPortName(name string) *ReadinessCheck

SetPortName sets the port name on the readiness check.

func (*ReadinessCheck) SetPreserveLastResponse added in v0.8.0

func (rc *ReadinessCheck) SetPreserveLastResponse(preserve bool) *ReadinessCheck

SetPreserveLastResponse sets the preserve last response flag on the readiness check.

func (*ReadinessCheck) SetProtocol added in v0.8.0

func (rc *ReadinessCheck) SetProtocol(proto string) *ReadinessCheck

SetProtocol sets the protocol on the readiness check.

func (*ReadinessCheck) SetTimeout added in v0.8.0

func (rc *ReadinessCheck) SetTimeout(timeout time.Duration) *ReadinessCheck

SetTimeout sets the timeout on the readiness check.

type ReadinessCheckResult added in v0.8.0

type ReadinessCheckResult struct {
	Name         string                `json:"name"`
	TaskID       string                `json:"taskId"`
	Ready        bool                  `json:"ready"`
	LastResponse ReadinessLastResponse `json:"lastResponse,omitempty"`
}

ReadinessCheckResult is the result of a readiness check.

type ReadinessLastResponse added in v0.8.0

type ReadinessLastResponse struct {
	Body        string `json:"body"`
	ContentType string `json:"contentType"`
	Status      int    `json:"status"`
}

ReadinessLastResponse holds the result of the last response embedded in a readiness check result.

type Residency added in v0.8.0

type Residency struct {
	TaskLostBehavior                 TaskLostBehaviorType `json:"taskLostBehavior,omitempty"`
	RelaunchEscalationTimeoutSeconds int                  `json:"relaunchEscalationTimeoutSeconds,omitempty"`
}

Residency defines how terminal states of tasks with local persistent volumes are handled

func (*Residency) SetRelaunchEscalationTimeout added in v0.8.0

func (r *Residency) SetRelaunchEscalationTimeout(timeout time.Duration) *Residency

SetRelaunchEscalationTimeout sets the residency relaunch escalation timeout with seconds precision

func (*Residency) SetTaskLostBehavior added in v0.8.0

func (r *Residency) SetTaskLostBehavior(behavior TaskLostBehaviorType) *Residency

SetTaskLostBehavior sets the residency behavior

type Resources added in v0.8.0

type Resources struct {
	Cpus float64 `json:"cpus"`
	Mem  float64 `json:"mem"`
	Disk float64 `json:"disk,omitempty"`
	Gpus int32   `json:"gpus,omitempty"`
}

Resources are the full set of resources for a task

func NewResources added in v0.8.0

func NewResources() *Resources

NewResources creates an empty Resources

type Secret added in v0.8.0

type Secret struct {
	EnvVar string
	Source string
}

Secret is the environment variable and secret store path associated with a secret. The value for EnvVar is populated from the env field, and Source is populated from the secrets field of the application json.

type Stats added in v0.6.0

type Stats struct {
	Counts   map[string]int     `json:"counts"`
	LifeTime map[string]float64 `json:"lifeTime"`
}

Stats is a collection of aggregate statistics about an application's tasks

type StatusCondition added in v0.8.0

type StatusCondition struct {
	Name        string `json:"name,omitempty"`
	Value       string `json:"value,omitempty"`
	Reason      string `json:"reason,omitempty"`
	LastChanged string `json:"lastChanged,omitempty"`
	LastUpdated string `json:"lastUpdated,omitempty"`
}

StatusCondition describes info about a status change

type StepActions added in v0.1.0

type StepActions struct {
	Actions []struct {
		Action string `json:"action"` // 1.1.2 and after
		Type   string `json:"type"`   // 1.1.1 and before
		App    string `json:"app"`
	}
}

StepActions is a series of deployment steps

type Subscriptions

type Subscriptions struct {
	CallbackURLs []string `json:"callbackUrls"`
}

Subscriptions is a collection to urls that marathon is implementing a callback on

type TCPHealthCheck added in v0.8.0

type TCPHealthCheck struct {
	Endpoint string `json:"endpoint,omitempty"`
}

TCPHealthCheck describes a TCP based health check

func NewTCPHealthCheck added in v0.8.0

func NewTCPHealthCheck() *TCPHealthCheck

NewTCPHealthCheck creates an empty TCPHealthCheck

func (*TCPHealthCheck) SetEndpoint added in v0.8.0

func (t *TCPHealthCheck) SetEndpoint(endpoint string) *TCPHealthCheck

SetEndpoint sets the name of the pod health check endpoint

type Task

type Task struct {
	ID                 string               `json:"id"`
	AppID              string               `json:"appId"`
	Host               string               `json:"host"`
	HealthCheckResults []*HealthCheckResult `json:"healthCheckResults"`
	Ports              []int                `json:"ports"`
	ServicePorts       []int                `json:"servicePorts"`
	SlaveID            string               `json:"slaveId"`
	StagedAt           string               `json:"stagedAt"`
	StartedAt          string               `json:"startedAt"`
	State              string               `json:"state"`
	IPAddresses        []*IPAddress         `json:"ipAddresses"`
	Version            string               `json:"version"`
}

Task is the definition for a marathon task

func (*Task) HasHealthCheckResults

func (r *Task) HasHealthCheckResults() bool

HasHealthCheckResults checks if the task has any health checks

type TaskLostBehaviorType added in v0.8.0

type TaskLostBehaviorType string

TaskLostBehaviorType sets action taken when the resident task is lost

const (
	// TaskLostBehaviorTypeWaitForever indicates to not take any action when the resident task is lost
	TaskLostBehaviorTypeWaitForever TaskLostBehaviorType = "WAIT_FOREVER"
	// TaskLostBehaviorTypeRelaunchAfterTimeout indicates to try relaunching the lost resident task on
	// another node after the relaunch escalation timeout has elapsed
	TaskLostBehaviorTypeRelaunchAfterTimeout TaskLostBehaviorType = "RELAUNCH_AFTER_TIMEOUT"
)

type TaskStats added in v0.6.0

type TaskStats struct {
	Stats Stats `json:"stats"`
}

TaskStats is a container for Stats

type Tasks

type Tasks struct {
	Tasks []Task `json:"tasks"`
}

Tasks is a collection of marathon tasks

type TmpEnvSecret added in v0.8.0

type TmpEnvSecret struct {
	Secret string `json:"secret,omitempty"`
}

TmpEnvSecret holds the secret values deserialized from the environment variables field

type TmpSecret added in v0.8.0

type TmpSecret struct {
	Source string `json:"source,omitempty"`
}

TmpSecret holds the deserialized secrets field in a Marathon application configuration

type UnreachableStrategy added in v0.8.0

type UnreachableStrategy struct {
	EnabledUnreachableStrategy
	AbsenceReason string
}

UnreachableStrategy is the unreachable strategy applied to an application.

func (*UnreachableStrategy) MarshalJSON added in v0.8.0

func (us *UnreachableStrategy) MarshalJSON() ([]byte, error)

MarshalJSON marshals the unreachable strategy.

func (*UnreachableStrategy) SetExpungeAfterSeconds added in v0.8.0

func (us *UnreachableStrategy) SetExpungeAfterSeconds(cap float64) *UnreachableStrategy

SetExpungeAfterSeconds sets the period after which instance will be expunged.

func (*UnreachableStrategy) SetInactiveAfterSeconds added in v0.8.0

func (us *UnreachableStrategy) SetInactiveAfterSeconds(cap float64) *UnreachableStrategy

SetInactiveAfterSeconds sets the period after which instance will be marked as inactive.

func (*UnreachableStrategy) UnmarshalJSON added in v0.8.0

func (us *UnreachableStrategy) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the given JSON into an UnreachableStrategy. It populates parameters for present strategies, and otherwise only sets the absence reason.

type UnusedOffer added in v0.8.0

type UnusedOffer struct {
	Offer     Offer    `json:"offer"`
	Reason    []string `json:"reason"`
	Timestamp string   `json:"timestamp"`
}

UnusedOffer contains which offers weren't used and why

type UpdateGroupOpts added in v0.1.0

type UpdateGroupOpts struct {
	Force bool `url:"force,omitempty"`
}

UpdateGroupOpts contains a payload for UpdateGroup method

force:		overrides a currently running deployment.

type UpgradeStrategy

type UpgradeStrategy struct {
	MinimumHealthCapacity *float64 `json:"minimumHealthCapacity,omitempty"`
	MaximumOverCapacity   *float64 `json:"maximumOverCapacity,omitempty"`
}

UpgradeStrategy is the upgrade strategy applied to an application.

func (*UpgradeStrategy) SetMaximumOverCapacity added in v0.7.0

func (us *UpgradeStrategy) SetMaximumOverCapacity(cap float64) *UpgradeStrategy

SetMaximumOverCapacity sets the maximum over capacity.

func (*UpgradeStrategy) SetMinimumHealthCapacity added in v0.7.0

func (us *UpgradeStrategy) SetMinimumHealthCapacity(cap float64) *UpgradeStrategy

SetMinimumHealthCapacity sets the minimum health capacity.

type VersionInfo

type VersionInfo struct {
	LastScalingAt      string `json:"lastScalingAt,omitempty"`
	LastConfigChangeAt string `json:"lastConfigChangeAt,omitempty"`
}

VersionInfo is the application versioning details from marathon

type Volume

type Volume struct {
	ContainerPath string            `json:"containerPath,omitempty"`
	HostPath      string            `json:"hostPath,omitempty"`
	External      *ExternalVolume   `json:"external,omitempty"`
	Mode          string            `json:"mode,omitempty"`
	Persistent    *PersistentVolume `json:"persistent,omitempty"`
	Secret        string            `json:"secret,omitempty"`
}

Volume is the docker volume details associated to the container

func (*Volume) EmptyExternalVolume added in v0.4.0

func (v *Volume) EmptyExternalVolume() *Volume

EmptyExternalVolume emptys the external volume definition

func (*Volume) EmptyPersistentVolume added in v0.8.0

func (v *Volume) EmptyPersistentVolume() *Volume

EmptyPersistentVolume empties the persistent volume definition

func (*Volume) SetExternalVolume added in v0.4.0

func (v *Volume) SetExternalVolume(name, provider string) *ExternalVolume

SetExternalVolume define external elements for a volume

name: the name of the volume
provider: the provider of the volume (e.g. dvdi)

func (*Volume) SetPersistentVolume added in v0.8.0

func (v *Volume) SetPersistentVolume() *PersistentVolume

SetPersistentVolume defines persistent properties for volume

func (*Volume) SetSecretVolume added in v0.8.0

func (v *Volume) SetSecretVolume(containerPath, secret string) *Volume

SetSecretVolume defines secret and containerPath for volume

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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