Refactor module binding to rely on Type
This commit is contained in:
@@ -25,9 +25,8 @@ type HubRoute struct {
|
||||
// UpstreamURL/ProxyURL 在构造 Registry 时提前解析完成,便于后续请求快速复用。
|
||||
UpstreamURL *url.URL
|
||||
ProxyURL *url.URL
|
||||
// ModuleKey/Module 记录当前 hub 选用的模块及其元数据,便于日志与观测。
|
||||
ModuleKey string
|
||||
Module hubmodule.ModuleMetadata
|
||||
// Module 记录当前 hub 选用的模块元数据,便于日志与观测。
|
||||
Module hubmodule.ModuleMetadata
|
||||
// CacheStrategy 代表模块默认策略与 hub 覆盖后的最终结果。
|
||||
CacheStrategy hubmodule.CacheStrategyProfile
|
||||
}
|
||||
@@ -134,7 +133,6 @@ func buildHubRoute(cfg *config.Config, hub config.HubConfig) (*HubRoute, error)
|
||||
CacheTTL: effectiveTTL,
|
||||
UpstreamURL: upstreamURL,
|
||||
ProxyURL: proxyURL,
|
||||
ModuleKey: runtime.Module.Key,
|
||||
Module: runtime.Module,
|
||||
CacheStrategy: runtime.CacheStrategy,
|
||||
}, nil
|
||||
|
||||
@@ -54,8 +54,8 @@ func TestHubRegistryLookupByHost(t *testing.T) {
|
||||
if route.CacheStrategy.ValidationMode == "" {
|
||||
t.Fatalf("cache strategy validation mode should not be empty")
|
||||
}
|
||||
if route.ModuleKey != "docker" {
|
||||
t.Fatalf("expected docker module, got %s", route.ModuleKey)
|
||||
if route.Module.Key != "docker" {
|
||||
t.Fatalf("expected docker module, got %s", route.Module.Key)
|
||||
}
|
||||
|
||||
if route.UpstreamURL.String() != "https://registry-1.docker.io" {
|
||||
|
||||
@@ -113,7 +113,7 @@ func encodeHubBindings(routes []server.HubRoute) []hubBindingPayload {
|
||||
for _, route := range routes {
|
||||
result = append(result, hubBindingPayload{
|
||||
HubName: route.Config.Name,
|
||||
ModuleKey: route.ModuleKey,
|
||||
ModuleKey: route.Module.Key,
|
||||
Domain: route.Config.Domain,
|
||||
Port: route.ListenPort,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user