@@ -28,15 +28,16 @@ import (
2828)
2929
3030const (
31- progressModePercent = "percent"
32- progressModeIndeterminate = "indeterminate"
33- mirrorBaseURL = "https://git-devops.opencsg.com/opensource/apps/-/raw/main"
34- repoRawBaseURL = "https://git-devops.opencsg.com/opensource/csghub-lite/-/raw/main"
35- installTimeout = 20 * time .Minute
36- latestVersionCacheTTL = 10 * time .Minute
37- latestVersionTimeout = 3 * time .Second
38- installerPTYCols = 120
39- installerPTYRows = 36
31+ progressModePercent = "percent"
32+ progressModeIndeterminate = "indeterminate"
33+ mirrorBaseURL = "https://git-devops.opencsg.com/opensource/apps/-/raw/main"
34+ repoRawBaseURL = "https://git-devops.opencsg.com/opensource/csghub-lite/-/raw/main"
35+ installTimeout = 20 * time .Minute
36+ latestVersionCacheTTL = 10 * time .Minute
37+ latestVersionTimeout = 3 * time .Second
38+ latestVersionResponseLimit = 64 * 1024
39+ installerPTYCols = 120
40+ installerPTYRows = 36
4041)
4142
4243var versionTokenPattern = regexp .MustCompile (`(?i)v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?` )
@@ -237,9 +238,9 @@ func appSpecs() []appSpec {
237238 disabledReason : csgclawDisabledReason (),
238239 versionArgs : []string {"--version" },
239240 latest : & latestVersionSource {
240- baseURL : "https://api.github .com/repos/OpenCSGs/csgclaw /releases/latest" ,
241+ baseURL : "https://csgclaw.opencsg .com/releases/latest" ,
241242 envVar : "CSGHUB_LITE_CSGCLAW_LATEST_URL" ,
242- format : "github-release " ,
243+ format : "version-json " ,
243244 },
244245 unix : & scriptSource {
245246 mirrorURL : "https://csgclaw.opencsg.com/install.sh" ,
@@ -513,7 +514,7 @@ func (m *Manager) fetchLatestVersion(ctx context.Context, spec appSpec) (string,
513514 reqCtx , cancel := context .WithTimeout (ctx , latestVersionTimeout )
514515 defer cancel ()
515516 req , err := http .NewRequestWithContext (reqCtx , http .MethodGet , baseURL + "/latest" , nil )
516- if spec .latest .format == "github-release" {
517+ if spec .latest .format == "github-release" || spec . latest . format == "version-json" {
517518 req , err = http .NewRequestWithContext (reqCtx , http .MethodGet , baseURL , nil )
518519 }
519520 if err != nil {
@@ -527,7 +528,7 @@ func (m *Manager) fetchLatestVersion(ctx context.Context, spec appSpec) (string,
527528 if resp .StatusCode < http .StatusOK || resp .StatusCode >= http .StatusMultipleChoices {
528529 return "" , fmt .Errorf ("latest endpoint returned %s" , resp .Status )
529530 }
530- data , err := io .ReadAll (io .LimitReader (resp .Body , 1024 ))
531+ data , err := io .ReadAll (io .LimitReader (resp .Body , latestVersionResponseLimit ))
531532 if err != nil {
532533 return "" , err
533534 }
@@ -540,6 +541,15 @@ func (m *Manager) fetchLatestVersion(ctx context.Context, spec appSpec) (string,
540541 }
541542 return strings .TrimSpace (payload .TagName ), nil
542543 }
544+ if spec .latest .format == "version-json" {
545+ var payload struct {
546+ Version string `json:"version"`
547+ }
548+ if err := json .Unmarshal (data , & payload ); err != nil {
549+ return "" , err
550+ }
551+ return strings .TrimSpace (payload .Version ), nil
552+ }
543553 return strings .TrimSpace (string (data )), nil
544554}
545555
0 commit comments