contracts

package
v0.0.0-...-84afe80 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package contracts contains all necessary interface and models necessary for communication and sharing within the agent.

Package contracts contains objects for parsing and encoding MDS/SSM messages.

Index

Constants

View Source
const (
	/*
		NOTE: Following constants are meant to be used for setting plugin status only
	*/
	// AssociationStatusPending represents Pending status
	AssociationStatusPending = "Pending"
	// AssociationStatusAssociated represents Associated status
	AssociationStatusAssociated = "Associated"
	// AssociationStatusInProgress represents InProgress status
	AssociationStatusInProgress = "InProgress"
	// AssociationStatusSuccess represents Success status
	AssociationStatusSuccess = "Success"
	// AssociationStatusFailed represents Failed status
	AssociationStatusFailed = "Failed"
	// AssociationStatusTimedOut represents TimedOut status
	AssociationStatusTimedOut = "TimedOut"
)
View Source
const (
	/*
		NOTE: Following constants are meant to be used for setting error codes in plugin status only. If these are used
		for setting plugin status -> the status will not be appropriately aggregated.
	*/
	// AssociationErrorCodeInvalidAssociation represents InvalidAssociation Error
	AssociationErrorCodeInvalidAssociation = "InvalidAssoc"
	// AssociationErrorCodeInvalidExpression represents InvalidExpression Error
	AssociationErrorCodeInvalidExpression = "InvalidExpression"
	// AssociationErrorCodeExecutionError represents Execution Error
	AssociationErrorCodeExecutionError = "ExecutionError"
	// AssociationErrorCodeListAssociationError represents ListAssociation Error
	AssociationErrorCodeListAssociationError = "ListAssocError"
	// AssociationErrorCodeSubmitAssociationError represents SubmitAssociation Error
	AssociationErrorCodeSubmitAssociationError = "SubmitAssocError"
	// AssociationErrorCodeStuckAtInProgressError represents association stuck in InProgress Error
	AssociationErrorCodeStuckAtInProgressError = "StuckAtInProgress"
	// AssociationErrorCodeNoError represents no error
	AssociationErrorCodeNoError = ""
)
View Source
const (
	// DocumentPendingMessages represents the summary message for pending association
	AssociationPendingMessage string = "Association is pending"
	// DocumentInProgressMessage represents the summary message for inprogress association
	AssociationInProgressMessage string = "Executing association"
)
View Source
const (
	// ParamTypeString represents the Param Type is String
	ParamTypeString = "String"
	// ParamTypeStringList represents the Param Type is StringList
	ParamTypeStringList = "StringList"
)
View Source
const (
	//MaximumPluginOutputSize represents the maximum output size that agent supports
	MaximumPluginOutputSize = 2400
)

Variables

This section is empty.

Functions

func TruncateOutput

func TruncateOutput(stdout string, stderr string, capacity int) (response string)

TruncateOutput truncates the output

Types

type AdditionalInfo

type AdditionalInfo struct {
	Agent               AgentInfo      `json:"agent"`
	DateTime            string         `json:"dateTime"`
	RunID               string         `json:"runId"`
	RuntimeStatusCounts map[string]int `json:"runtimeStatusCounts"`
}

AdditionalInfo section in agent response

type AgentConfiguration

type AgentConfiguration struct {
	AgentInfo  AgentInfo
	InstanceID string
}

AgentConfiguration is a struct that stores information about the agent and instance.

type AgentInfo

type AgentInfo struct {
	Lang      string `json:"lang"`
	Name      string `json:"name"`
	Os        string `json:"os"`
	OsVersion string `json:"osver"`
	Version   string `json:"ver"`
}

AgentInfo represents the agent response

type Configuration

type Configuration struct {
	Settings                interface{}
	Properties              interface{}
	OutputS3KeyPrefix       string
	OutputS3BucketName      string
	OrchestrationDirectory  string
	MessageId               string
	BookKeepingFileName     string
	PluginName              string
	PluginID                string
	DefaultWorkingDirectory string
}

Configuration represents a plugin configuration as in the json format.

type DocumentContent

type DocumentContent struct {
	SchemaVersion string                   `json:"schemaVersion"`
	Description   string                   `json:"description"`
	RuntimeConfig map[string]*PluginConfig `json:"runtimeConfig"`
	MainSteps     []*InstancePluginConfig  `json:"mainSteps"`
	Parameters    map[string]*Parameter    `json:"parameters"`
}

DocumentContent object which represents ssm document content.

type ICoreModule

type ICoreModule interface {
	ModuleName() string
	ModuleExecute(context context.T) (err error)
	ModuleRequestStop(stopType StopType) (err error)
}

ICoreModule is the very much of core itself will be implemented as plugins that are simply hardcoded to run with agent framework. The hardcoded plugins will implement the ICoreModule

type IPlugin

type IPlugin interface {
	Name() string
	Execute(context context.T, input PluginConfig) (output PluginResult, err error)
	RequestStop(stopType StopType) (err error)
}

IPlugin is interface for authoring a functionality of work. Every functionality of work is implemented as a plugin.

type IWorkerPlugin

type IWorkerPlugin IPlugin

IWorkerPlugin is the plugins which do not form part of core These plugins are invoked on demand.

type InstancePluginConfig

type InstancePluginConfig struct {
	Action      string      `json:"action"` // plugin name
	Inputs      interface{} `json:"inputs"` // Properties
	MaxAttempts int         `json:"maxAttempts"`
	Name        string      `json:"name"` // unique identifier
	OnFailure   string      `json:"onFailure"`
	Settings    interface{} `json:"settings"`
	Timeout     int         `json:"timeoutSeconds"`
}

InstancePluginConfig stores plugin configuration

type Parameter

type Parameter struct {
	DefaultVal     interface{} `json:"default"`
	Description    string      `json:"description"`
	ParamType      string      `json:"type"`
	AllowedVal     []string    `json:"allowedValues"`
	AllowedPattern string      `json:"allowedPattern"`
}

A Parameter in the DocumentContent of an MDS message.

type Plugin

type Plugin struct {
	Configuration
	PluginResult
}

Plugin wraps the plugin configuration and plugin result.

type PluginConfig

type PluginConfig struct {
	Settings    interface{} `json:"settings"`
	Properties  interface{} `json:"properties"`
	Description string      `json:"description"`
}

PluginConfig stores plugin configuration

type PluginInput

type PluginInput struct {
}

PluginInput represents the input of the plugin.

type PluginOutput

type PluginOutput struct {
	ExitCode int
	Status   ResultStatus
	Stdout   string
	Stderr   string
}

PluginOutput represents the output of the plugin.

func (*PluginOutput) AppendError

func (out *PluginOutput) AppendError(log log.T, message string)

AppendError adds errors to PluginOutput StandardErr.

func (*PluginOutput) AppendErrorf

func (out *PluginOutput) AppendErrorf(log log.T, format string, params ...interface{})

AppendErrorf adds errors to PluginOutput StandardErr with formatting parameters.

func (*PluginOutput) AppendInfo

func (out *PluginOutput) AppendInfo(log log.T, message string)

AppendInfo adds info to PluginOutput StandardOut.

func (*PluginOutput) AppendInfof

func (out *PluginOutput) AppendInfof(log log.T, format string, params ...interface{})

AppendInfof adds info to PluginOutput StandardOut with formatting parameters.

func (*PluginOutput) MarkAsFailed

func (out *PluginOutput) MarkAsFailed(log log.T, err error)

MarkAsFailed Failed marks plugin as Failed

func (*PluginOutput) MarkAsInProgress

func (out *PluginOutput) MarkAsInProgress()

MarkAsInProgress marks plugin as In Progress.

func (*PluginOutput) MarkAsSucceeded

func (out *PluginOutput) MarkAsSucceeded()

MarkAsSucceeded marks plugin as Successful.

func (*PluginOutput) MarkAsSuccessWithReboot

func (out *PluginOutput) MarkAsSuccessWithReboot()

MarkAsSuccessWithReboot marks plugin as Successful and requests a reboot.

func (*PluginOutput) String

func (p *PluginOutput) String() (response string)

type PluginResult

type PluginResult struct {
	PluginName         string       `json:"pluginName"`
	Status             ResultStatus `json:"status"`
	Code               int          `json:"code"`
	Output             interface{}  `json:"output"`
	StartDateTime      time.Time    `json:"startDateTime"`
	EndDateTime        time.Time    `json:"endDateTime"`
	OutputS3BucketName string       `json:"outputS3BucketName"`
	OutputS3KeyPrefix  string       `json:"outputS3KeyPrefix"`
	Error              error        `json:"-"`
	StandardOutput     string       `json:"standardOutput"`
	StandardError      string       `json:"standardError"`
}

PluginResult represents a plugin execution result.

type PluginRuntimeStatus

type PluginRuntimeStatus struct {
	Status             ResultStatus `json:"status"`
	Code               int          `json:"code"`
	Name               string       `json:"name"`
	Output             string       `json:"output"`
	StartDateTime      string       `json:"startDateTime"`
	EndDateTime        string       `json:"endDateTime"`
	OutputS3BucketName string       `json:"outputS3BucketName"`
	OutputS3KeyPrefix  string       `json:"outputS3KeyPrefix"`
	StandardOutput     string       `json:"standardOutput"`
	StandardError      string       `json:"standardError"`
}

PluginRuntimeStatus represents plugin runtime status section in agent response

type ResultStatus

type ResultStatus string

ResultStatus provides the granular status of a plugin. These are internal states maintained by agent during the execution of a command/config

const (
	ResultStatusNotStarted       ResultStatus = "NotStarted"
	ResultStatusInProgress       ResultStatus = "InProgress"
	ResultStatusSuccess          ResultStatus = "Success"
	ResultStatusSuccessAndReboot ResultStatus = "SuccessAndReboot"
	ResultStatusPassedAndReboot  ResultStatus = "PassedAndReboot"
	ResultStatusFailed           ResultStatus = "Failed"
	ResultStatusCancelled        ResultStatus = "Cancelled"
	ResultStatusTimedOut         ResultStatus = "TimedOut"
)

func MergeResultStatus

func MergeResultStatus(current ResultStatus, new ResultStatus) (merged ResultStatus)

MergeResultStatus takes two ResultStatuses (presumably from sub-tasks) and decides what the overall task status should be

type StopType

type StopType string
const (
	StopTypeSoftStop StopType = "SoftStop"
	StopTypeHardStop StopType = "HardStop"
)

Jump to

Keyboard shortcuts

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