Documentation ¶
Index ¶
- Constants
- Variables
- func ParseVersion(version string) (semver.Version, error)
- func UnsafeDeletePreviousVersionFiles(dirPath string) error
- type ApplicationConfig
- type Channel
- type CheckStatus
- type DeleteMode
- type ReplacementFile
- type RollbackResults
- type ServData
- type SourceCheckStatus
- type SourceStatus
- type UpdateConfig
- func (uc *UpdateConfig) CheckAllSourcesForUpdates() (Version, SourceCheckStatus)
- func (uc *UpdateConfig) CheckForUpdates() (Version, SourceCheckStatus)
- func (uc *UpdateConfig) DoUpdate(ver Version, curAppDir string, ...) (_ UpdateResult, err error)
- func (uc *UpdateConfig) LoadFilesToDir(ver Version, dirPath string) error
- type UpdateResult
- type UpdateSource
- type UpdateSourceGitRepo
- type UpdateSourceServer
- type Version
Constants ¶
const ( SourceLabelGitRepo = "SourceGitRepo" SourceLabelServer = "SourceServer" )
const ReplacementFileDefaultMode = fs.FileMode(0644)
const ReplacementFileInfoUseDefaultOrExistedFilePerm = 9999
const ZipArchiveExtension = ".zip"
Variables ¶
var ErrorFailUpdateRollback = errors.New("error. update rollback failed")
var ErrorResponseCodeIsNotOK = errors.New("error. response code is not OK")
var TarGzArchiveExtensions = []string{".tgz", ".tar.gz"}
Functions ¶
func ParseVersion ¶
func UnsafeDeletePreviousVersionFiles ¶
USE CAREFULLY! Func will delete files by extension. (CHECK oldVersionReplacedFilesExtension)
func delete only files which have old and new version. Example:
/test.txt.old
/test.txt
/example.exe
func delete test.txt.old
Types ¶
type ApplicationConfig ¶
type ApplicationConfig struct { ValidateFilesNamesRegexes []*regexp.Regexp // match with any regex file is valid ShowPrepareVersionErr bool // on false block non-critical errors // contains filtered or unexported fields }
func NewApplicationConfig ¶
func NewApplicationConfig(version string, channels []Channel, validateFilesNamesRegex []*regexp.Regexp) (ApplicationConfig, error)
version - current version with channel
channels - channels, that used in project versioning. channels ODER IS IMPORTANT. First in slice - max priority EXCEPT Release Channel, it always has max priority
validateFilesNamesRegex - match with any regex file is valid, if nil .*GOOS_GOARCH.* is used
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func NewChannel ¶
func NewReleaseChannel ¶
type CheckStatus ¶
type CheckStatus int
const ( CheckSuccess CheckStatus = iota // no errors CheckHasErrors // process finished successfully, but with errors CheckFailure // process interrupted by error )
type DeleteMode ¶
type DeleteMode int
const ( // DeleteModPureDelete just delete files, can't delete files, which now are used or executed in Windows OS DeleteModPureDelete DeleteMode = iota // DeleteModKillProcess successfully delete all prev version files, even if they are used by current process (for all os) // after successful delete KILL current process (stop on err, no rollback) DeleteModKillProcess // DeleteModRerunExec successfully delete all prev version files, even if they are used by current process (for all os) // after successful delete RUN exe (stop on err, no rollback) DeleteModRerunExec )
type ReplacementFile ¶
type ReplacementFile struct { FileName string Mode fs.FileMode // use ReplacementFileInfoUseDefaultOrExistedFilePerm to set default ReplacementFileDefaultMode or if file already exist, existed file permission PreventFileLoading bool // is file should be skipped during update // contains filtered or unexported fields }
type RollbackResults ¶
type RollbackResults UpdateResult
func UnsafeRollbackUpdate ¶
func UnsafeRollbackUpdate(dirPath string) (*RollbackResults, error)
USE CAREFULLY! If prev update is not deleted func rename files by extension. (CHECK oldVersionReplacedFilesExtension)
func (*RollbackResults) DeleteLoadedVersionFiles ¶
func (rbRes *RollbackResults) DeleteLoadedVersionFiles(mod DeleteMode, params ...interface{}) error
check documentation in DeletePreviousVersionFiles func
type ServData ¶
type ServData struct { VersionFolderUrl string `json:"folder_url"` // version folder url Name string `json:"name"` // release summary Description string `json:"description"` // release description Version string `json:"version"` // version tag Assets []struct { Filename string `json:"filename"` // version files filenames, filenames adds to VersionFolderUrl } `json:"assets"` // version files }
type SourceCheckStatus ¶
type SourceCheckStatus struct { SourcesStatuses []SourceStatus // sources statuses Status CheckStatus // sources check status }
type SourceStatus ¶
type SourceStatus struct { Source UpdateSource // link to source instance, cast it to base class Errors []error // source errors Status CheckStatus // source status }
type UpdateConfig ¶
type UpdateConfig struct { ApplicationConfig ApplicationConfig Sources []UpdateSource // source oder is source PRIORITY }
func (*UpdateConfig) CheckAllSourcesForUpdates ¶
func (uc *UpdateConfig) CheckAllSourcesForUpdates() (Version, SourceCheckStatus)
looking for new version in defined sources
func (*UpdateConfig) CheckForUpdates ¶
func (uc *UpdateConfig) CheckForUpdates() (Version, SourceCheckStatus)
looking for new version in defined sources. First source response with Ok code and any versions (even nil) will stop any other attempt to check other sources
func (*UpdateConfig) DoUpdate ¶
func (uc *UpdateConfig) DoUpdate(ver Version, curAppDir string, getReplacementFileInfo func(loadedFilename string) (ReplacementFile, error), doBeforeUpdate func() error) (_ UpdateResult, err error)
Load Files -> Check hash -> doBeforeUpdate() -> get file names from getReplacementFileInfo function, safe replace it if file exist in folder (curAppDir or cur exec file folder on empty string). Do rollback on any trouble
func (*UpdateConfig) LoadFilesToDir ¶
func (uc *UpdateConfig) LoadFilesToDir(ver Version, dirPath string) error
For Debug purpose
Load version update files to dirPath dir ¶
Empty string dirPath for place file near to executable file
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
func (*UpdateResult) DeletePreviousVersionFiles ¶
func (uR *UpdateResult) DeletePreviousVersionFiles(mode DeleteMode, params ...interface{}) error
Delete prev version files, choose to delete type based on your purpose
DeleteModPureDelete no params ¶
DeleteModKillProcess no params ¶
DeleteModRerunExec use params to set executable file call args
func (*UpdateResult) RerunExe ¶
func (uR *UpdateResult) RerunExe(exeArgs []string) error
func (*UpdateResult) RollbackChanges ¶
func (uR *UpdateResult) RollbackChanges() error
type UpdateSource ¶
type UpdateSource interface { SourceLabel() string // contains filtered or unexported methods }
type UpdateSourceGitRepo ¶
type UpdateSourceGitRepo struct { UserName string RepoName string UseDraftVersions bool // on true releases marked as draft load and validate as others PersonalAccessToken string // ONLY FOR DEBUG PURPOSE }
func (*UpdateSourceGitRepo) SourceLabel ¶
func (sGit *UpdateSourceGitRepo) SourceLabel() string
type UpdateSourceServer ¶
type UpdateSourceServer struct {
UpdatesMapURL string
}
func (*UpdateSourceServer) SourceLabel ¶
func (sServ *UpdateSourceServer) SourceLabel() string