Documentation ¶
Overview ¶
Package updateutil contains updater specific utilities.
Package updateutil contains updater specific utilities.
Package updateutil contains updater specific utilities.
Index ¶
- func BuildMessage(err error, format string, params ...interface{}) (message string)
- func BuildMessages(errs []error, format string, params ...interface{}) (message string)
- func BuildUpdateCommand(cmd string, arg string, value string) string
- func CompareVersion(versionOne string, versionTwo string) (int, error)
- func ConvertToUpdateErrorCode(errorCodes ...string) updateconstants.ErrorCode
- func GetCommandPid(cmd *exec.Cmd) int
- func GetManifestURLFromSourceUrl(sourceURL string) (string, error)
- func GetStableURLFromManifestURL(manifestURL string, identity identity.IAgentIdentity) (string, error)
- func InstallerFilePath(updateRoot string, packageName string, version string, installer string) (file string)
- func IsIdentityRuntimeConfigSupported(sourceVersion string) bool
- func IsV1UpdatePlugin(SourceVersion string) bool
- func ResolveAgentReleaseBucketURL(region string, identity identity.IAgentIdentity) string
- func ResolveUpdateRoot(sourceVersion string) (string, error)
- func UnInstallerFilePath(updateRoot string, packageName string, version string, uninstaller string) (file string)
- func UpdateArtifactFolder(updateRoot string, packageName string, version string) (folder string)
- func UpdateContextFilePath(updateRoot string) (filePath string)
- func UpdateOutputDirectory(updateRoot string) string
- func UpdatePluginResultFilePath(updateRoot string) (filePath string)
- func UpdateStdErrPath(updateRoot string, fileName string) string
- func UpdateStdOutPath(updateRoot string, fileName string) string
- func UpdaterFilePath(updateRoot string, updaterPackageName string, version string) (filePath string)
- type CommandExecutionSettings
- type T
- type UpdatePluginResult
- type Utility
- func (util *Utility) CreateInstanceInfo(log log.T) (context updateinfo.T, err error)
- func (util *Utility) CreateUpdateDownloadFolder() (folder string, err error)
- func (util *Utility) ExeCommand(input *CommandExecutionSettings) (int, updateconstants.UpdateScriptExitCode, error)
- func (util *Utility) ExeCommandOutput(log log.T, cmd string, parameters []string, workingDir string, ...) (output string, err error)
- func (util *Utility) ExeCommandWithSlice(input *CommandExecutionSettings) (int, updateconstants.UpdateScriptExitCode, error)
- func (util *Utility) ExecCommandWithOutput(input *CommandExecutionSettings) (pId int, updExitCode updateconstants.UpdateScriptExitCode, ...)
- func (util *Utility) GetExecutionTimeOut() int
- func (util *Utility) IsDiskSpaceSufficientForUpdate(log log.T) (bool, error)
- func (util *Utility) IsServiceRunning(log log.T, i updateinfo.T) (result bool, err error)
- func (util *Utility) IsWorkerRunning(log log.T) (result bool, err error)
- func (util *Utility) LoadUpdateDocumentState(ctx context.T, commandId string) error
- func (util *Utility) NewExeCommandOutput(log log.T, cmd string, parameters []string, workingDir string, ...) (output string, err error)
- func (util *Utility) SaveUpdatePluginResult(log log.T, updateRoot string, updateResult *UpdatePluginResult) (err error)
- func (util *Utility) UpdateExecutionTimeOut(timeout int)
- func (util *Utility) UpdateInstallDelayer(ctx context.T, updateRoot string) error
- func (util *Utility) VerifyInstalledVersion(log log.T, targetVersion string) updateconstants.ErrorCode
- func (util *Utility) WaitForServiceToStart(log log.T, i updateinfo.T, targetVersion string) (result bool, svcRunningErr error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildMessage ¶
BuildMessage builds the messages with provided format, error and arguments
func BuildMessages ¶
BuildMessages builds the messages with provided format, error and arguments
func BuildUpdateCommand ¶
BuildUpdateCommand builds command string with argument and value
func ConvertToUpdateErrorCode ¶
func ConvertToUpdateErrorCode(errorCodes ...string) updateconstants.ErrorCode
ConvertToUpdateErrorCode joins the error string array passed and converts to update error code
func GetCommandPid ¶
getCommandPid returns the pid of the process if present, defaults to pid -1
func GetManifestURLFromSourceUrl ¶
GetManifestURLFromSourceUrl parses source url passed to the updater and generates the url for manifest
func GetStableURLFromManifestURL ¶
func GetStableURLFromManifestURL(manifestURL string, identity identity.IAgentIdentity) (string, error)
func InstallerFilePath ¶
func InstallerFilePath(updateRoot string, packageName string, version string, installer string) (file string)
InstallerFilePath returns Installer file path
func IsIdentityRuntimeConfigSupported ¶
IsIdentityRuntimeConfigSupported returns true if source agent version is greater than 3.1.282.0, any error defaults to false this logic is required to ensure that updater does not rely on an old runtime config if an agent has been downgraded from a version that supported identity runtimeconfig and also to skip the runtimeconfig check when we know it does not exist
func IsV1UpdatePlugin ¶
IsV1UpdatePlugin returns true if source agent version is equal or below 3.0.882.0, any error defaults to false
this logic is required since moving logic from plugin to updater would otherwise lead to duplicate aws console logging when upgrading from V1UpdatePlugin agents
func ResolveAgentReleaseBucketURL ¶
func ResolveAgentReleaseBucketURL(region string, identity identity.IAgentIdentity) string
ResolveAgentReleaseBucketURL makes best effort to generate an url for the ssm agent bucket
func ResolveUpdateRoot ¶
ResolveUpdateRoot returns the platform specific path to update artifacts
func UnInstallerFilePath ¶
func UnInstallerFilePath(updateRoot string, packageName string, version string, uninstaller string) (file string)
UnInstallerFilePath returns UnInstaller file path
func UpdateArtifactFolder ¶
UpdateArtifactFolder returns the folder path for storing all the update artifacts
func UpdateContextFilePath ¶
UpdateContextFilePath returns Context file path
func UpdateOutputDirectory ¶
UpdateOutputDirectory returns output directory
func UpdatePluginResultFilePath ¶
UpdatePluginResultFilePath returns update plugin result file path
func UpdateStdErrPath ¶
UpdateStdErrPath returns stand error file path
func UpdateStdOutPath ¶
UpdateStdOutPath returns stand output file path
Types ¶
type T ¶
type T interface { CreateUpdateDownloadFolder() (folder string, err error) ExeCommand(input *CommandExecutionSettings) (pid int, exitCode updateconstants.UpdateScriptExitCode, err error) ExeCommandWithSlice(input *CommandExecutionSettings) (pid int, exitCode updateconstants.UpdateScriptExitCode, err error) ExecCommandWithOutput(input *CommandExecutionSettings) (pId int, updExitCode updateconstants.UpdateScriptExitCode, stdoutBytes *bytes.Buffer, errorBytes *bytes.Buffer, cmdErr error) IsServiceRunning(log log.T, i updateinfo.T) (result bool, err error) IsWorkerRunning(log log.T) (result bool, err error) WaitForServiceToStart(log log.T, i updateinfo.T, targetVersion string) (result bool, err error) SaveUpdatePluginResult(log log.T, updaterRoot string, updateResult *UpdatePluginResult) (err error) IsDiskSpaceSufficientForUpdate(log log.T) (bool, error) UpdateInstallDelayer(ctx context.T, updateRoot string) error LoadUpdateDocumentState(ctx context.T, commandId string) error VerifyInstalledVersion(log log.T, targetVersion string) updateconstants.ErrorCode UpdateExecutionTimeOut(int) GetExecutionTimeOut() int }
T represents the interface for Update utility
type UpdatePluginResult ¶
type UpdatePluginResult struct { StandOut string `json:"StandOut"` StartDateTime time.Time `json:"StartDateTime"` }
UpdatePluginResult represents Agent update plugin result
func LoadUpdatePluginResult ¶
func LoadUpdatePluginResult( log log.T, updateRoot string) (updateResult *UpdatePluginResult, err error)
LoadUpdatePluginResult loads UpdatePluginResult from local storage
type Utility ¶
type Utility struct { Context context.T CustomUpdateExecutionTimeoutInSeconds int ProcessExecutor executor.IExecutor UpdateDocState contracts.DocumentState }
Utility implements interface T
func (*Utility) CreateInstanceInfo ¶
CreateInstanceInfo create instance related information such as region, platform and arch
func (*Utility) CreateUpdateDownloadFolder ¶
CreateUpdateDownloadFolder creates folder for storing update downloads
func (*Utility) ExeCommand ¶
func (util *Utility) ExeCommand(input *CommandExecutionSettings) (int, updateconstants.UpdateScriptExitCode, error)
ExeCommand executes shell command
func (*Utility) ExeCommandOutput ¶
func (util *Utility) ExeCommandOutput( log log.T, cmd string, parameters []string, workingDir string, outputRoot string, stdOutFileName string, stdErrFileName string, usePlatformSpecificCommand bool) (output string, err error)
TODO move to commandUtil ExeCommandOutput executes shell command and returns the stdout
func (*Utility) ExeCommandWithSlice ¶
func (util *Utility) ExeCommandWithSlice(input *CommandExecutionSettings) (int, updateconstants.UpdateScriptExitCode, error)
ExeCommandWithSlice executes shell command
func (*Utility) ExecCommandWithOutput ¶
func (util *Utility) ExecCommandWithOutput(input *CommandExecutionSettings) (pId int, updExitCode updateconstants.UpdateScriptExitCode, stdoutBytes *bytes.Buffer, errorBytes *bytes.Buffer, cmdErr error)
ExecCommandWithOutput executes shell command and returns output and error of command execution
func (*Utility) GetExecutionTimeOut ¶
GetExecutionTimeOut returns the command execution timeout
func (*Utility) IsDiskSpaceSufficientForUpdate ¶
IsDiskSpaceSufficientForUpdate loads disk space info and checks the available bytes Returns true if the system has at least 100 Mb for available disk space or false if it is less than 100 Mb
func (*Utility) IsServiceRunning ¶
IsServiceRunning returns is service running
func (*Utility) IsWorkerRunning ¶
IsWorkerRunning returns true if ssm-agent-worker running
func (*Utility) LoadUpdateDocumentState ¶
LoadUpdateDocumentState loads the update document state from Pending queue
func (*Utility) NewExeCommandOutput ¶
func (util *Utility) NewExeCommandOutput( log log.T, cmd string, parameters []string, workingDir string, outputRoot string, stdoutWriter io.Writer, stderrWriter io.Writer, usePlatformSpecificCommand bool) (output string, err error)
TODO move to commandUtil ExeCommandOutput executes shell command and returns the stdout
func (*Utility) SaveUpdatePluginResult ¶
func (util *Utility) SaveUpdatePluginResult( log log.T, updateRoot string, updateResult *UpdatePluginResult) (err error)
SaveUpdatePluginResult saves UpdatePluginResult to the local storage
func (*Utility) UpdateExecutionTimeOut ¶
UpdateExecutionTimeOut updates the command execution timeout
func (*Utility) UpdateInstallDelayer ¶
UpdateInstallDelayer delays the agent install when domain join reboot doc found
func (*Utility) VerifyInstalledVersion ¶
func (util *Utility) VerifyInstalledVersion(log log.T, targetVersion string) updateconstants.ErrorCode
VerifyInstalledVersion verifies whether the expected version is installed on Windows instance. For linux, this function always return true
func (*Utility) WaitForServiceToStart ¶
func (util *Utility) WaitForServiceToStart(log log.T, i updateinfo.T, targetVersion string) (result bool, svcRunningErr error)
WaitForServiceToStart wait for service to start and returns is service started
Directories ¶
Path | Synopsis |
---|---|
Package updateconstants contains constants related to update
|
Package updateconstants contains constants related to update |
Package updatemanifest implements the logic for the ssm agent s3 manifest.
|
Package updatemanifest implements the logic for the ssm agent s3 manifest. |
Package updates3util implements the logic for s3 update download
|
Package updates3util implements the logic for s3 update download |