feat: add resilient updates and access controls
Container-Image veröffentlichen / container (push) Has been cancelled
Container-Image veröffentlichen / container (push) Has been cancelled
This commit is contained in:
1 parent
a000152423
commit
f02ec9977c
41 files changed
+3277
-151
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package updateprotocol
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
var releaseVersionPattern = regexp.MustCompile(`^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$`)
|
||||
|
||||
const (
|
||||
PhaseIdle = "idle"
|
||||
PhaseQueued = "queued"
|
||||
PhasePulling = "pulling"
|
||||
PhaseRestarting = "restarting"
|
||||
PhaseVerifying = "verifying"
|
||||
PhaseComplete = "complete"
|
||||
PhaseFailed = "failed"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Version string `json:"version"`
|
||||
RegistryUsername string `json:"registry_username"`
|
||||
RegistryToken string `json:"registry_token"`
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
Phase string `json:"phase"`
|
||||
TargetVersion string `json:"target_version,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
StartedAt time.Time `json:"started_at,omitempty"`
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
func (s Status) Busy() bool {
|
||||
return s.Phase == PhaseQueued || s.Phase == PhasePulling || s.Phase == PhaseRestarting || s.Phase == PhaseVerifying
|
||||
}
|
||||
|
||||
func ValidVersion(version string) bool {
|
||||
return len(version) <= 64 && releaseVersionPattern.MatchString(version)
|
||||
}
|
||||
Reference in new issue
Block a user