Documentation ¶
Overview ¶
Package contracts helps persist documents state to disk
Package contracts provides model definitions for document state ¶
Package contracts provides model definitions for document state ¶
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
- func IsManagedInstanceIncompatibleAWSSSMDocument(documentName string) bool
- func IsPreconditionEnabled(schemaVersion string) (response bool)
- func RemoveDependencyOnInstanceMetadata(context context.T, docState *DocumentState) error
- func UpdateDocState(docResult *DocumentResult, docState *DocumentState)
- type AdditionalInfo
- type AgentConfiguration
- type AgentInfo
- type CancelCommandInfo
- type Configuration
- type DocumentContent
- type DocumentInfo
- type DocumentResult
- type DocumentState
- type DocumentType
- type ICoreModule
- type IOConfiguration
- type IPlugin
- type IWorkerPlugin
- type InstancePluginConfig
- type OSProcInfo
- type Parameter
- type Plugin
- type PluginConfig
- type PluginInput
- type PluginOutputter
- type PluginResult
- type PluginRuntimeStatus
- type PluginState
- type ResultStatus
- type StopType
Constants ¶
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" )
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 = "" )
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" )
const ( // ParamTypeString represents the Param Type is String ParamTypeString = "String" // ParamTypeStringList represents the Param Type is StringList ParamTypeStringList = "StringList" // ParamTypeStringMap represents the param type is StringMap ParamTypeStringMap = "StringMap" )
Variables ¶
This section is empty.
Functions ¶
func IsManagedInstanceIncompatibleAWSSSMDocument ¶
IsManagedInstanceIncompatibleAWSSSMDocument checks if doc could contain incompatible code for managed instance
func IsPreconditionEnabled ¶
IsPreconditionEnabled checks if precondition support is enabled by checking document schema version
func RemoveDependencyOnInstanceMetadata ¶
func RemoveDependencyOnInstanceMetadata(context context.T, docState *DocumentState) error
RemoveDependencyOnInstanceMetadata looks for array of commands which will be executed as a part of this document and replace the incompatible code.
func UpdateDocState ¶
func UpdateDocState(docResult *DocumentResult, docState *DocumentState)
UpdateDocState updates the current document state
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 ¶
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 CancelCommandInfo ¶
type CancelCommandInfo struct { CancelMessageID string CancelCommandID string Payload string DebugInfo string }
CancelCommandInfo represents information relevant to a cancel-command that agent receives TODO This might be revisited when Agent-cli is written to list previously executed commands
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 Preconditions map[string][]string IsPreconditionEnabled bool CurrentAssociations []string }
Configuration represents a plugin configuration as in the json format.
type DocumentContent ¶
type DocumentContent struct { SchemaVersion string `json:"schemaVersion" yaml:"schemaVersion"` Description string `json:"description" yaml:"description"` RuntimeConfig map[string]*PluginConfig `json:"runtimeConfig" yaml:"runtimeConfig"` MainSteps []*InstancePluginConfig `json:"mainSteps" yaml:"mainSteps"` Parameters map[string]*Parameter `json:"parameters" yaml:"parameters"` }
DocumentContent object which represents ssm document content.
type DocumentInfo ¶
type DocumentInfo struct { // DocumentID is a unique name for file system // For Association, DocumentID = AssociationID.RunID // For RunCommand, DocumentID = CommandID DocumentID string CommandID string AssociationID string InstanceID string MessageID string RunID string CreatedDate string DocumentName string DocumentVersion string DocumentStatus ResultStatus RunCount int ProcInfo OSProcInfo }
DocumentInfo represents information stored as interim state for a document
type DocumentResult ¶
type DocumentResult struct { DocumentName string DocumentVersion string MessageID string AssociationID string PluginResults map[string]*PluginResult Status ResultStatus LastPlugin string NPlugins int }
DocumentResult is a struct that stores information about the result of the document
type DocumentState ¶
type DocumentState struct { DocumentInformation DocumentInfo DocumentType DocumentType SchemaVersion string InstancePluginsInformation []PluginState CancelInformation CancelCommandInfo IOConfig IOConfiguration }
DocumentState represents information relevant to a command that gets executed by agent
func (*DocumentState) IsAssociation ¶
func (c *DocumentState) IsAssociation() bool
IsAssociation returns if documentType is association
func (*DocumentState) IsRebootRequired ¶
func (c *DocumentState) IsRebootRequired() bool
IsRebootRequired returns if reboot is needed
type DocumentType ¶
type DocumentType string
DocumentType defines the type of document persists locally.
const ( // SendCommand represents document type for send command SendCommand DocumentType = "SendCommand" // CancelCommand represents document type for cancel command CancelCommand DocumentType = "CancelComamnd" // Association represents document type for association Association DocumentType = "Association" // SendCommandOffline represents document type for send command received from offline service SendCommandOffline DocumentType = "SendCommandOffline" // CancelCommandOffline represents document type for cancel command received from offline service CancelCommandOffline DocumentType = "CancelCommandOffline" )
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 IOConfiguration ¶
type IOConfiguration struct { OrchestrationDirectory string OutputS3BucketName string OutputS3KeyPrefix string }
IOConfiguration represents information relevant to the output sources of a command
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" yaml:"action"` // plugin name Inputs interface{} `json:"inputs" yaml:"inputs"` // Properties MaxAttempts int `json:"maxAttempts" yaml:"maxAttempts"` Name string `json:"name" yaml:"name"` // unique identifier OnFailure string `json:"onFailure" yaml:"onFailure"` Settings interface{} `json:"settings" yaml:"settings"` Timeout int `json:"timeoutSeconds" yaml:"timeoutSeconds"` Preconditions map[string][]string `json:"precondition" yaml:"precondition"` }
InstancePluginConfig stores plugin configuration
type OSProcInfo ¶
OSProcInfo represents information about the new process for outofproc
type Parameter ¶
type Parameter struct { DefaultVal interface{} `json:"default" yaml:"default"` Description string `json:"description" yaml:"description"` ParamType string `json:"type" yaml:"type"` AllowedVal []string `json:"allowedValues" yaml:"allowedValues"` AllowedPattern string `json:"allowedPattern" yaml:"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" yaml:"settings"` Properties interface{} `json:"properties" yaml:"properties"` Description string `json:"description" yaml:"description"` }
PluginConfig stores plugin configuration
type PluginOutputter ¶
type PluginOutputter interface { String() string MarkAsFailed(log log.T, err error) MarkAsSucceeded() MarkAsInProgress() MarkAsSuccessWithReboot() MarkAsCancelled() MarkAsShutdown() AppendInfo(log log.T, message string) AppendInfof(log log.T, format string, params ...interface{}) AppendError(log log.T, message string) AppendErrorf(log log.T, format string, params ...interface{}) // getters/setters GetStatus() ResultStatus GetStdout() string GetStderr() string GetExitCode() int SetStatus(ResultStatus) SetExitCode(int) }
PluginOutputter defines interface for PluginOutput type
type PluginResult ¶
type PluginResult struct { PluginID string `json:"pluginID"` 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 PluginState ¶
type PluginState struct { Configuration Configuration Name string //TODO truncate this struct Result PluginResult Id string }
PluginState represents information stored as interim state for any plugin This has both the configuration with which a plugin gets executed and a corresponding plugin result.
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 represents NotStarted status ResultStatusNotStarted ResultStatus = "NotStarted" // ResultStatusInProgress represents InProgress status ResultStatusInProgress ResultStatus = "InProgress" // ResultStatusSuccess represents Success status ResultStatusSuccess ResultStatus = "Success" // ResultStatusSuccessAndReboot represents SuccessAndReboot status ResultStatusSuccessAndReboot ResultStatus = "SuccessAndReboot" // ResultStatusPassedAndReboot represents PassedAndReboot status ResultStatusPassedAndReboot ResultStatus = "PassedAndReboot" // ResultStatusFailed represents Failed status ResultStatusFailed ResultStatus = "Failed" // ResultStatusCancelled represents Cancelled status ResultStatusCancelled ResultStatus = "Cancelled" // ResultStatusTimedOut represents TimedOut status ResultStatusTimedOut ResultStatus = "TimedOut" // ResultStatusSkipped represents Skipped status ResultStatusSkipped ResultStatus = "Skipped" )
func DocumentResultAggregator ¶
func DocumentResultAggregator(log log.T, pluginID string, pluginOutputs map[string]*PluginResult) (ResultStatus, map[string]int, map[string]*PluginRuntimeStatus)
DocumentResultAggregator aggregates the result from the plugins to construct the agent response
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
func (ResultStatus) IsReboot ¶
func (rs ResultStatus) IsReboot() bool
IsReboot checks whether the result is reboot or not
func (ResultStatus) IsSuccess ¶
func (rs ResultStatus) IsSuccess() bool
IsSuccess checks whether the result is success or not