Documentation ¶
Overview ¶
Package updateutil contains updater specific utilities.
Package updateutil contains updater specific utilities.
Package updateutil contains updater specific utilities.
Package updateutil contains updater specific utilities.
Package updateutil contains updater specific utilities.
Index ¶
- Constants
- 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 InstallerFilePath(updateRoot string, packageName string, version string) (file string)
- func UnInstallerFilePath(updateRoot string, packageName string, version 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 UpdateStandErrPath(updateRoot string, fileName string) string
- func UpdateStandOutPath(updateRoot string, fileName string) string
- func UpdaterFilePath(updateRoot string, updaterPackageName string, version string) (filePath string)
- func VersionCompare(versionl string, versionr string) (result int, err error)
- type ErrorCode
- type InstanceContext
- type Mock
- func (m *Mock) CreateInstanceContext(log log.T) (context *InstanceContext, err error)
- func (m *Mock) CreateUpdateDownloadFolder() (folder string, err error)
- func (m *Mock) ExeCommand(log log.T, cmd string, workingDir string, updaterRoot string, stdOut string, ...) (err error)
- func (m *Mock) SaveUpdatePluginResult(log log.T, updaterRoot string, updateResult *UpdatePluginResult) (err error)
- type T
- type UpdatePluginResult
- type Utility
- func (util *Utility) CreateInstanceContext(log log.T) (context *InstanceContext, err error)
- func (util *Utility) CreateUpdateDownloadFolder() (folder string, err error)
- func (util *Utility) ExeCommand(log log.T, cmd string, workingDir string, updaterRoot string, stdOut string, ...) (err error)
- func (util *Utility) IsDiskSpaceSufficientForUpdate(log log.T) (bool, error)
- func (util *Utility) IsPlatformSupportedForUpdate(log log.T) (result bool, err error)
- func (util *Utility) IsServiceRunning(log log.T, i *InstanceContext) (result bool, err error)
- func (util *Utility) SaveUpdatePluginResult(log log.T, updateRoot string, updateResult *UpdatePluginResult) (err error)
Constants ¶
const ( // UpdaterPackageNamePrefix represents the name of Updater Package UpdaterPackageNamePrefix = "-updater" // HashType represents the default hash type HashType = "sha256" // Updater represents Updater name Updater = "updater" // UpdateContextFileName represents Update context json file UpdateContextFileName = "updatecontext.json" // UpdatePluginResultFileName represents Update plugin result file name UpdatePluginResultFileName = "updatepluginresult.json" // DefaultOutputFolder represents default location for storing output files DefaultOutputFolder = "output" // DefaultStandOut represents the default file name for update stand output DefaultStandOut = "stdout" // DefaultStandErr represents the default file name for update stand error DefaultStandErr = "stderr" // RegionHolder represents Place holder for Region RegionHolder = "{Region}" // PackageNameHolder represents Place holder for package name PackageNameHolder = "{PackageName}" // PackageVersionHolder represents Place holder for package version PackageVersionHolder = "{PackageVersion}" // FileNameHolder represents Place holder for file name FileNameHolder = "{FileName}" // PlatformHolder represents Place holder for platform PlatformHolder = "{Platform}" // ArchHolder represents Place holder for Arch ArchHolder = "{Arch}" // CompressedHolder represents Place holder for compress format CompressedHolder = "{Compressed}" // PlatformLinux represents linux PlatformLinux = "linux" // PlatformAmazonLinux represents amazon linux PlatformAmazonLinux = "amazon" // PlatformRedHat represents RedHat PlatformRedHat = "red hat" // PlatformUbuntu represents Ubuntu PlatformUbuntu = "ubuntu" // PlatformCentOS represents CentOS PlatformCentOS = "centos" // PlatformWindows represents windows PlatformWindows = "windows" // DefaultUpdateExecutionTimeoutInSeconds represents default timeout time for execution update related scripts in seconds DefaultUpdateExecutionTimeoutInSeconds = 30 // PipelineTestVersion represents fake version for pipeline tests PipelineTestVersion = "255.0.0.0" )
const ( // UpdateCmd represents the command argument for update UpdateCmd = "update" // SourceVersionCmd represents the command argument for source version SourceVersionCmd = "source.version" // SourceLocationCmd represents the command argument for source location SourceLocationCmd = "source.location" // SourceHashCmd represents the command argument for source hash value SourceHashCmd = "source.hash" // TargetVersionCmd represents the command argument for target version TargetVersionCmd = "target.version" // TargetLocationCmd represents the command argument for target location TargetLocationCmd = "target.location" // TargetHashCmd represents the command argument for target hash value TargetHashCmd = "target.hash" // PackageNameCmd represents the command argument for package name PackageNameCmd = "package.name" // MessageIDCmd represents the command argument for message id MessageIDCmd = "messageid" // StdoutFileName represents the command argument for standard output file StdoutFileName = "stdout" // StderrFileName represents the command argument for standard error file StderrFileName = "stderr" // OutputKeyPrefixCmd represents the command argument for output key prefix OutputKeyPrefixCmd = "output.key" // OutputBucketNameCmd represents the command argument for output bucket name OutputBucketNameCmd = "output.bucket" )
const ( // Installer represents Install shell script Installer = "install.sh" // UnInstaller represents Uninstall shell script UnInstaller = "uninstall.sh" )
const (
// CompressFormat represents the compress format for linux platform
CompressFormat = "tar.gz"
)
const MinimumDiskSpaceForUpdate int64 = 104857600
MinimumDiskSpaceForUpdate represents 100 Mb in bytes
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 InstallerFilePath ¶
InstallerFilePath returns Installer file path
func UnInstallerFilePath ¶
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 UpdateStandErrPath ¶
UpdateStandErrPath returns stand error file path
func UpdateStandOutPath ¶
UpdateStandOutPath returns stand output file path
Types ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode is types of Error Codes
const ( // ErrorInvalidSourceVersion represents Source version is not supported ErrorInvalidSourceVersion ErrorCode = "ErrorInvalidSourceVersion" // ErrorInvalidTargetVersion represents Target version is not supported ErrorInvalidTargetVersion ErrorCode = "ErrorInvalidTargetVersion" // ErrorAttemptToDowngrade represents An update is attempting to downgrade Ec2Config to a lower version ErrorAttemptToDowngrade ErrorCode = "ErrorAttempToDowngrade" // ErrorInitializationFailed represents An update is failed to initialize ErrorInitializationFailed ErrorCode = "ErrorInitializationFailed" // ErrorInvalidPackage represents Installation package file is invalid ErrorInvalidPackage ErrorCode = "ErrorInvalidPackage" // ErrorPackageNotAccessible represents Installation package file is not accessible ErrorPackageNotAccessible ErrorCode = "ErrorPackageNotAccessible" // ErrorInvalidCertificate represents Installation package file doesn't contain valid certificate ErrorInvalidCertificate ErrorCode = "ErrorInvalidCertificate" // ErrorInvalidManifest represents Invalid manifest file ErrorInvalidManifest ErrorCode = "ErrorInvalidManifest" // ErrorInvalidManifestLocation represents Invalid manifest file location ErrorInvalidManifestLocation ErrorCode = "ErrorInvalidManifestLocation" // ErrorUninstallFailed represents Uninstall failed ErrorUninstallFailed ErrorCode = "ErrorUninstallFailed" // ErrorInstallFailed represents Install failed ErrorInstallFailed ErrorCode = "ErrorInstallFailed" // ErrorCannotStartService represents Cannot start Ec2Config service ErrorCannotStartService ErrorCode = "ErrorCannotStartService" // ErrorCannotStopService represents Cannot stop Ec2Config service ErrorCannotStopService ErrorCode = "ErrorCannotStopService" // ErrorTimeout represents Installation time-out ErrorTimeout ErrorCode = "ErrorTimeout" // ErrorUnexpected represents Unexpected Error ErrorUnexpected ErrorCode = "ErrorUnexpected" // ErrorEnvironmentIssue represents Unexpected Error ErrorEnvironmentIssue ErrorCode = "ErrorEnvironmentIssue" // ErrorLoadingAgentVersion represents failed for loading agent version ErrorLoadingAgentVersion ErrorCode = "ErrorLoadingAgentVersion" )
type InstanceContext ¶
type InstanceContext struct { Region string Platform string PlatformVersion string InstallerName string Arch string CompressFormat string }
InstanceContext holds information for the instance
func (*InstanceContext) FileName ¶
func (i *InstanceContext) FileName(packageName string) string
FileName generates downloadable file name base on agreed convension
func (*InstanceContext) IsPlatformUsingSystemD ¶
func (i *InstanceContext) IsPlatformUsingSystemD(log log.T) (result bool, err error)
IsPlatformUsingSystemD returns if SystemD is the default Init for the Linux platform
type Mock ¶
Mock stands for a mocked updateutil.
func NewMockDefault ¶
func NewMockDefault() *Mock
NewMockDefault returns an instance of Mock with default expectations set.
func (*Mock) CreateInstanceContext ¶
func (m *Mock) CreateInstanceContext(log log.T) (context *InstanceContext, err error)
CreateInstanceContext mocks the CreateInstanceContext function.
func (*Mock) CreateUpdateDownloadFolder ¶
CreateUpdateDownloadFolder mocks the CreateUpdateDownloadFolder function.
func (*Mock) ExeCommand ¶
func (m *Mock) ExeCommand(log log.T, cmd string, workingDir string, updaterRoot string, stdOut string, stdErr string, isAsync bool) (err error)
ExeCommand mocks the ExeCommand function.
func (*Mock) SaveUpdatePluginResult ¶
func (m *Mock) SaveUpdatePluginResult(log log.T, updaterRoot string, updateResult *UpdatePluginResult) (err error)
SaveUpdatePluginResult mocks the SaveUpdatePluginResult function.
type T ¶
type T interface { CreateInstanceContext(log log.T) (context *InstanceContext, err error) CreateUpdateDownloadFolder() (folder string, err error) ExeCommand(log log.T, cmd string, workingDir string, updaterRoot string, stdOut string, stdErr string, isAsync bool) (err error) IsServiceRunning(log log.T, i *InstanceContext) (result bool, err error) SaveUpdatePluginResult(log log.T, updaterRoot string, updateResult *UpdatePluginResult) (err error) IsDiskSpaceSufficientForUpdate(log log.T) (bool, error) IsPlatformSupportedForUpdate(log log.T) (bool, error) }
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{}
Utility implements interface T
func (*Utility) CreateInstanceContext ¶
func (util *Utility) CreateInstanceContext(log log.T) (context *InstanceContext, err error)
CreateInstanceContext 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( log log.T, cmd string, workingDir string, updaterRoot string, stdOut string, stdErr string, isAsync bool) (err error)
ExeCommand executes shell command
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) IsPlatformSupportedForUpdate ¶
IsPlatformSupportedForUpdate checks for each platform type and make sure current platform has no restrictio on agent update Returns true if the update is allowed, otherwise return false
func (*Utility) IsServiceRunning ¶
IsServiceRunning returns is service running
func (*Utility) SaveUpdatePluginResult ¶
func (util *Utility) SaveUpdatePluginResult( log log.T, updateRoot string, updateResult *UpdatePluginResult) (err error)
SaveUpdatePluginResult saves UpdatePluginResult to the local storage