types

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unknown state (default value)
	Unknown ExecutionState = "Unknown"

	// Pending script execution
	Pending ExecutionState = "Pending"

	// Running script state
	Running ExecutionState = "Running"

	// Failed to execute script
	Failed = "Failed"

	// Succeeded state when successfully completed the script execution
	Succeeded = "Succeeded"

	// TimedOut state when time timit is reached and scrip has not completed yet
	TimedOut = "TimedOut"

	// Canceled state when customer canceled the script execution
	Canceled = "Canceled"
)

Variables

View Source
var (
	CmdInstallTemplate    = Cmd{Name: "Install", ShouldReportStatus: false, FailExitCode: 52}
	CmdEnableTemplate     = Cmd{Name: "Enable", ShouldReportStatus: true, FailExitCode: 3}
	CmdDisableTemplate    = Cmd{Name: "Disable", ShouldReportStatus: false, FailExitCode: 3}
	CmdUpdateTemplate     = Cmd{Name: "Update", ShouldReportStatus: false, FailExitCode: 3}
	CmdUninstallTemplate  = Cmd{Name: "Uninstall", ShouldReportStatus: false, FailExitCode: 3}
	CmdRunServiceTemplate = Cmd{Name: "RunService", ShouldReportStatus: true, FailExitCode: 3}

	CmdTemplates = map[string]Cmd{
		"install":    CmdInstallTemplate,
		"enable":     CmdEnableTemplate,
		"disable":    CmdDisableTemplate,
		"update":     CmdUpdateTemplate,
		"uninstall":  CmdUninstallTemplate,
		"runService": CmdRunServiceTemplate,
	}
)

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Name               string       // human readable string
	ShouldReportStatus bool         // determines if running this should report the status of the run command
	FailExitCode       int          // exitCode to use when commands fail
	Functions          CmdFunctions // functions used by the command
}

func (Cmd) InitializeFunctions

func (command Cmd) InitializeFunctions(input CmdFunctions) Cmd

type CmdFunctions

type CmdFunctions struct {
	Invoke       cmdFunc          // associated function
	Pre          preFunc          // executed before any status is reported
	ReportStatus reportStatusFunc // function to report status. Useful to write in .status file for RC and report to HGAP for Immediate Run Command.
	Cleanup      cleanupFunc      // function called after the extension has reached a terminal state to perform cleanup steps
}

type ExecutionState

type ExecutionState string

ExecutionState represents script current execution state

type FormattedMessage

type FormattedMessage struct {
	Lang    string `json:"lang"`
	Message string `json:"message"`
}

FormattedMessage is a struct used for serializing status

type GoalStateKey added in v1.3.14

type GoalStateKey struct {
	ExtensionName string
	SeqNumber     int
}

GoalStateKey is a unique identifier for a goal state item. It is used to store the goal state item in the event map.

type HandlerEnvironment

type HandlerEnvironment struct {
	Version            float64 `json:"version"`
	Name               string  `json:"name"`
	HandlerEnvironment struct {
		HeartbeatFile string `json:"heartbeatFile"`
		StatusFolder  string `json:"statusFolder"`
		ConfigFolder  string `json:"configFolder"`
		LogFolder     string `json:"logFolder"`
	}
}

HandlerEnvironment describes the handler environment configuration presented to the extension handler by the Azure Linux Guest Agent.

type RCMetadata

type RCMetadata struct {
	// Most recent sequence, which was previously traced by seqNumFile. This was
	// incorrect. The correct way is mrseq.  This file is auto-preserved by the agent.
	MostRecentSequence string

	// Filename where active process keeps track of process id and process start time
	PidFilePath string

	// DownloadDir is where we store the downloaded files in the "{downloadDir}/{seqnum}/file"
	// format and the logs as "{downloadDir}/{seqnum}/std(out|err)". Stored under dataDir
	// multiconfig support - when extName is set we use {downloadDir}/{extName}/...
	DownloadDir string

	// Download path is the full path where the files are stored.
	// E.g., /var/lib/waagent/run-command-handler/{downloadDir}/{seqnum}/file
	DownloadPath string

	// The name of the current extension. E.g., RC0001
	ExtName string

	// The sequence number. E.g., 1
	SeqNum int
}

func NewRCMetadata

func NewRCMetadata(extensionName string, seqNum int, downloadFolder string, dataDir string) RCMetadata

type RunCommandInstanceView

type RunCommandInstanceView struct {
	ExecutionState   ExecutionState `json:"executionState"`
	ExecutionMessage string         `json:"executionMessage"`
	Output           string         `json:"output"`
	Error            string         `json:"error"`
	ExitCode         int            `json:"exitCode"`
	StartTime        string         `json:"startTime"`
	EndTime          string         `json:"endTime"`
}

RunCommandInstanceView reports script execution status

func (RunCommandInstanceView) Marshal

func (instanceView RunCommandInstanceView) Marshal() ([]byte, error)

type Status

type Status struct {
	Operation        string           `json:"operation"`
	Status           StatusType       `json:"status"`
	FormattedMessage FormattedMessage `json:"formattedMessage"`
}

Status is used for serializing status in a manner the server understands

type StatusEventArgs added in v1.3.14

type StatusEventArgs struct {
	TopLevelStatus StatusItem
	StatusKey      GoalStateKey
}

StatusEventArgs is the event argument for the status change event for immediate run command.

type StatusItem

type StatusItem struct {
	Version      int    `json:"version"`
	TimestampUTC string `json:"timestampUTC"`
	Status       Status `json:"status"`
}

StatusItem is used to serialize an individual part of the status read by the server

type StatusReport

type StatusReport []StatusItem

StatusReport contains one or more status items and is the parent object

func NewStatusReport

func NewStatusReport(statusType StatusType, operation string, message string) StatusReport

type StatusType

type StatusType string

StatusType reports the execution status

const (
	// StatusTransitioning indicates the operation has begun but not yet completed
	StatusTransitioning StatusType = "transitioning"

	// StatusError indicates the operation failed
	StatusError StatusType = "error"

	// StatusSuccess indicates the operation succeeded
	StatusSuccess StatusType = "success"

	// StatusSkipped indicates the operation was skipped due to a precondition
	StatusSkipped StatusType = "skipped"
)

Jump to

Keyboard shortcuts

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