config

package
v0.0.0-...-68e3727 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

README

config

config

Package config handles agent configuration from a config file. It also defines the valid actions along with their types.

Usage

var (
	// ValidActions is a whitelist of configurable actions and their types
	ValidActions = map[string]ActionType{
		"create":               AsyncAction,
		"containerCreate":      AsyncAction,
		"delete":               AsyncAction,
		"containerDelete":      AsyncAction,
		"containerStart":       AsyncAction,
		"reboot":               AsyncAction,
		"containerReboot":      AsyncAction,
		"restart":              AsyncAction,
		"containerRestart":     AsyncAction,
		"poweroff":             AsyncAction,
		"containerPoweroff":    AsyncAction,
		"shutdown":             AsyncAction,
		"containerShutdown":    AsyncAction,
		"run":                  AsyncAction,
		"cpuMetrics":           InfoAction,
		"nicMetrics":           InfoAction,
		"diskMetrics":          InfoAction,
		"listImages":           InfoAction,
		"containerListImages":  InfoAction,
		"getImage":             InfoAction,
		"containerGetImage":    InfoAction,
		"deleteImage":          AsyncAction,
		"containerDeleteImage": AsyncAction,
		"fetchImage":           AsyncAction,
		"containerFetchImage":  AsyncAction,
		"listSnapshots":        InfoAction,
		"getSnapshot":          InfoAction,
		"createSnapshot":       AsyncAction,
		"deleteSnapshot":       AsyncAction,
		"rollbackSnapshot":     AsyncAction,
		"downloadSnapshot":     StreamAction,
	}
)
type Action
type Action struct {
	Type   ActionType
	Stages []Stage `json:"stages"`
}

Action is a set of stages and how they should be handled

type ActionType
type ActionType int

ActionType describes synchronicity of an action

const (
	// InfoAction is for synchronous information retrieval in JSON format
	InfoAction ActionType = iota
	// StreamAction is for synchronous data streaming
	StreamAction
	// AsyncAction is for asynchronous actions
	AsyncAction
)
type Config
type Config struct {
	Actions  map[string]Action  `json:"actions"`
	Services map[string]Service `json:"services"`
	DBPath   string             `json:"dbpath"`
}

Config contains all of the configuration data

func NewConfig
func NewConfig() *Config

NewConfig creates a new Config

func (*Config) AddConfig
func (c *Config) AddConfig(path string) error

AddConfig loads a configuration file

func (*Config) Fixup
func (c *Config) Fixup() error

Fixup does a bit of validation and initializtion

type Service
type Service struct {
	MaxPending uint   `json:"max_pending"`
	Port       uint   `json:"port"`
	Path       string `json:"path"`
}

Service is an HTTP service

type Stage
type Stage struct {
	Service string            `json:"service"`
	Method  string            `json:"method"`
	Args    map[string]string `json:"args"`
}

Stage is a single step for an action

-- Generated with godocdown

Documentation

Overview

Package config handles agent configuration from a config file. It also defines the valid actions along with their types.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidActions is a whitelist of configurable actions and their types
	ValidActions = map[string]ActionType{
		"create":               AsyncAction,
		"containerCreate":      AsyncAction,
		"delete":               AsyncAction,
		"containerDelete":      AsyncAction,
		"containerStart":       AsyncAction,
		"reboot":               AsyncAction,
		"containerReboot":      AsyncAction,
		"restart":              AsyncAction,
		"containerRestart":     AsyncAction,
		"poweroff":             AsyncAction,
		"containerPoweroff":    AsyncAction,
		"shutdown":             AsyncAction,
		"containerShutdown":    AsyncAction,
		"start":                AsyncAction,
		"cpuMetrics":           InfoAction,
		"nicMetrics":           InfoAction,
		"diskMetrics":          InfoAction,
		"listImages":           InfoAction,
		"containerListImages":  InfoAction,
		"getImage":             InfoAction,
		"containerGetImage":    InfoAction,
		"deleteImage":          AsyncAction,
		"containerDeleteImage": AsyncAction,
		"fetchImage":           AsyncAction,
		"containerFetchImage":  AsyncAction,
		"listSnapshots":        InfoAction,
		"getSnapshot":          InfoAction,
		"createSnapshot":       AsyncAction,
		"deleteSnapshot":       AsyncAction,
		"rollbackSnapshot":     AsyncAction,
		"downloadSnapshot":     StreamAction,
	}
)

Functions

This section is empty.

Types

type Action

type Action struct {
	Type   ActionType
	Stages []Stage `json:"stages"`
}

Action is a set of stages and how they should be handled

type ActionType

type ActionType int

ActionType describes synchronicity of an action

const (
	// InfoAction is for synchronous information retrieval in JSON format
	InfoAction ActionType = iota
	// StreamAction is for synchronous data streaming
	StreamAction
	// AsyncAction is for asynchronous actions
	AsyncAction
)

type Config

type Config struct {
	Actions  map[string]Action  `json:"actions"`
	Services map[string]Service `json:"services"`
	DBPath   string             `json:"dbpath"`
}

Config contains all of the configuration data

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config

func (*Config) AddConfig

func (c *Config) AddConfig(path string) error

AddConfig loads a configuration file

func (*Config) Fixup

func (c *Config) Fixup() error

Fixup does a bit of validation and initializtion

type Service

type Service struct {
	MaxPending uint   `json:"max_pending"`
	Port       uint   `json:"port"`
	Path       string `json:"path"`
}

Service is an HTTP service

type Stage

type Stage struct {
	Service string            `json:"service"`
	Method  string            `json:"method"`
	Args    map[string]string `json:"args"`
}

Stage is a single step for an action

Jump to

Keyboard shortcuts

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