Recognize local app states (T-202)

This commit is contained in:
ila
2026-07-16 17:00:06 +08:00
parent 2e21c9f327
commit 819b1cdf88
16 changed files with 1303 additions and 16 deletions
+4 -3
View File
@@ -13,6 +13,8 @@ import (
"regexp"
"strings"
"time"
"softbox.local/core/domain"
)
var (
@@ -23,7 +25,6 @@ var (
var (
appIDPattern = regexp.MustCompile(`^[a-z0-9-]+$`)
semVerPattern = regexp.MustCompile(`^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$`)
sha256Pattern = regexp.MustCompile(`^[0-9A-Fa-f]{64}$`)
iconRefPattern = regexp.MustCompile(`^sha256:[0-9A-Fa-f]{64}$`)
)
@@ -97,7 +98,7 @@ func validateManifest(manifest Manifest, expectedChannel ManifestChannel) error
if err != nil || offset != 0 {
return invalidField("generated_at", "must be an RFC3339 UTC timestamp")
}
if !semVerPattern.MatchString(manifest.MinBoxVersion) {
if _, err := domain.ParseSemVer(manifest.MinBoxVersion); err != nil {
return invalidField("min_box_version", "must be SemVer")
}
if err := validateSignature(manifest.Signature); err != nil {
@@ -127,7 +128,7 @@ func validateApp(app App) error {
if strings.TrimSpace(app.Description) == "" {
return invalidField("description", "must not be empty")
}
if !semVerPattern.MatchString(app.Version) {
if _, err := domain.ParseSemVer(app.Version); err != nil {
return invalidField("version", "must be SemVer")
}
if app.Channel != ReleaseStable {