feat(platform): expose deployed release
This commit is contained in:
@@ -57,6 +57,7 @@ func NewServer(cfg config.Config) http.Handler {
|
||||
AMapSecurityProxyEnabled: strings.TrimSpace(cfg.AMapSecurityCode) != "" && strings.TrimSpace(cfg.AMapServiceHost) != "",
|
||||
AMapSecurityCodeExposed: exposedAMapSecurityCode(cfg) != "",
|
||||
AMapSecurityServiceHost: strings.TrimSpace(cfg.AMapServiceHost),
|
||||
PlatformRelease: strings.TrimSpace(cfg.PlatformRelease),
|
||||
}))
|
||||
handler := static.Handler(cfg.StaticDir, api)
|
||||
handler = withAppConfig(handler, cfg)
|
||||
|
||||
@@ -23,6 +23,7 @@ type Config struct {
|
||||
AMapWebJSKey string
|
||||
AMapSecurityCode string
|
||||
AMapServiceHost string
|
||||
PlatformRelease string
|
||||
}
|
||||
|
||||
func Load() Config {
|
||||
@@ -43,6 +44,7 @@ func Load() Config {
|
||||
AMapWebJSKey: os.Getenv("AMAP_WEB_JS_KEY"),
|
||||
AMapSecurityCode: os.Getenv("AMAP_SECURITY_JS_CODE"),
|
||||
AMapServiceHost: os.Getenv("AMAP_SECURITY_SERVICE_HOST"),
|
||||
PlatformRelease: os.Getenv("PLATFORM_RELEASE"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,3 +14,13 @@ func TestLoadReadsRequestTimeout(t *testing.T) {
|
||||
t.Fatalf("RequestTimeout = %s, want 1.2s", cfg.RequestTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadReadsPlatformRelease(t *testing.T) {
|
||||
t.Setenv("PLATFORM_RELEASE", "platform-20260704153005")
|
||||
|
||||
cfg := Load()
|
||||
|
||||
if cfg.PlatformRelease != "platform-20260704153005" {
|
||||
t.Fatalf("PlatformRelease = %q", cfg.PlatformRelease)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,6 +895,7 @@ func TestHandlerOpsHealthIncludesVehicleServiceRuntime(t *testing.T) {
|
||||
AMapSecurityProxyEnabled: true,
|
||||
AMapSecurityCodeExposed: false,
|
||||
AMapSecurityServiceHost: "/_AMapService",
|
||||
PlatformRelease: "platform-20260704153005",
|
||||
}))
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/ops/health", nil)
|
||||
@@ -920,6 +921,9 @@ func TestHandlerOpsHealthIncludesVehicleServiceRuntime(t *testing.T) {
|
||||
if body.Data.Runtime.AMapSecurityServiceHost != "/_AMapService" {
|
||||
t.Fatalf("ops health should include AMap security service host, got %+v", body.Data.Runtime)
|
||||
}
|
||||
if body.Data.Runtime.PlatformRelease != "platform-20260704153005" {
|
||||
t.Fatalf("ops health should include platform release, got %+v", body.Data.Runtime)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerVehicleDataAPIsResolveVehicleKeyword(t *testing.T) {
|
||||
|
||||
@@ -349,4 +349,5 @@ type RuntimeInfo struct {
|
||||
AMapSecurityProxyEnabled bool `json:"amapSecurityProxyEnabled"`
|
||||
AMapSecurityCodeExposed bool `json:"amapSecurityCodeExposed"`
|
||||
AMapSecurityServiceHost string `json:"amapSecurityServiceHost"`
|
||||
PlatformRelease string `json:"platformRelease"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user