Version: v0.6.0 Latest Latest

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 5 Imported by: 0




View Source
const (
	TopicSeperator       = ":"
	OperationSubscribe   = "SUB"
	OperationUnsubscribe = "UNSUB"
	PipeConnected        = "CONN"
	PipeDisconnected     = "DISCONN"
View Source
const (
	// Request types (should not contain PrefixSeparator or TopicSeperator chars)
	RequestTargetAll = "ALL"
	RequestTargetID  = "ID"
	RequestTargetTag = "TAG"
	// Stage types
	StageBuild    = "build"
	StageTransfer = "transfer"
	StageInstall  = "install"
	StageRun      = "run"
	// Topic consts
	PrefixSeparator = "-"
	// Task types
	TaskTypeBuild  = 1
	TaskTypeDeploy = 2
View Source
const (
	// Response types (topics)
	ResponseLog           = "LOG" // logs
	ResponseAdvertisement = "ADV" // device advertisement
	ResponsePackage       = "PKG" // assembled artifacts

	// Log output constants
	ExecStart        = "EXEC-START"
	ExecEnd          = "EXEC-END"
	StageStart       = "STAGE-START"
	StageEnd         = "STAGE-END"
	CommandByAgent   = "$agent"
	CommandByManager = "$manager"


This section is empty.


func CompressFiles added in v0.5.0

func CompressFiles(paths ...string) ([]byte, error)

CompressFiles reads from given path and compresses in memory

func DecompressFiles added in v0.5.0

func DecompressFiles(b []byte, dir string) error

DecompressFiles decompresses from memory and writes to given directory

func FormatTopicID added in v0.5.0

func FormatTopicID(id string) string

func FormatTopicTag added in v0.5.0

func FormatTopicTag(tag string) string


type Announcement added in v0.5.0

type Announcement struct {
	Size int   `json:"s"`
	Type uint8 `json:"b,omitempty"`

Announcement carries information about a task

type Build added in v0.6.0

type Build struct {
	Commands  []string `json:"commands"`
	Artifacts []string `json:"artifacts"`

type Deploy added in v0.6.0

type Deploy struct {
	Install struct {
		Commands []string `json:"commands"`
	} `json:"install"`
	Run struct {
		Commands    []string `json:"commands"`
		AutoRestart bool     `json:"autoRestart"`
	} `json:"run"`
type Header struct {
	ID      string       `json:"id"`
	Debug   bool         `json:"debug,omitempty"`
	Created UnixTimeType `json:"createdAt"`

Header contains information that is common among task related structs

type Log

type Log struct {
	Task    string       `json:"task,omitempty"`
	Stage   string       `json:"stage,omitempty"`
	Command string       `json:"command,omitempty"` // TODO is command unique within a stage?
	Output  string       `json:"output,omitempty"`
	Error   bool         `json:"error,omitempty"`
	Time    UnixTimeType `json:"time,omitempty"`
	Debug   bool         `json:"-"`

type LogRequest

type LogRequest struct {
	IfModifiedSince UnixTimeType

type Message

type Message struct {
	Topic   string
	Payload []byte

type Package added in v0.5.0

type Package struct {
	Assembler string `json:"a"`
	Task      string `json:"t"`
	Payload   []byte `json:"p"`

type Pipe

type Pipe struct {
	RequestCh   chan Message
	ResponseCh  chan Message
	OperationCh chan Message

Pipe is a bi-directional channel structure

for communication between the clients and manager/agent

func NewPipe

func NewPipe() Pipe

NewPipe returns an instantiated Pipe

type RequestWrapper added in v0.5.0

type RequestWrapper struct {
	Announcement *Announcement `json:"a,omitempty"`
	LogRequest   *LogRequest   `json:"l,omitempty"`
	Command      *string       `json:"c,omitempty"`

RequestWrapper is the struct of messages sent to request topics

type Response

type Response struct {
	TargetID  string
	Logs      []Log
	OnRequest bool `json:",omitempty"` // true when logs were requested explicitly

type Target

type Target struct {
	AutoGenID string `json:"autoID,omitempty"`
	// active task
	TaskID             string           `json:"taskID"`
	TaskDebug          bool             `json:"taskDebug,omitempty"`
	TaskRun            []string         `json:"taskRun,omitempty"`
	TaskRunAutoRestart bool             `json:"taskRunAutoRestart,omitempty"`
	TaskHistory        map[string]uint8 `json:"taskHistory,omitempty"`

type TargetBase added in v0.6.0

type TargetBase struct {
	// omitempty for all fields to allow patch updates
	ID   string   `json:"id,omitempty"`
	Tags []string `json:"tags,omitempty"`

type Task

type Task struct {
	Build     *Build  `json:"bl,omitempty"`
	Deploy    *Deploy `json:"de,omitempty"`
	Artifacts []byte  `json:"ar,omitempty"`

Task is a struct with all the information for deployment on a target

func (*Task) Validate added in v0.6.0

func (t *Task) Validate() error

type UnixTimeType

type UnixTimeType int64

UnixTimeType is the type used for log timestamps

func UnixTime

func UnixTime() UnixTimeType

UnixTime returns the current unix time

Jump to

Keyboard shortcuts

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