From 2a12f01d3201eca76efa6e6cdbfea867dc490258 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Fri, 13 Jun 2025 17:33:05 +0300 Subject: [PATCH] container registry login host:port error fix (#170) Fixes #121 Gets port from the given registry server URL and use it in a RegistryClient. Signed-off-by: Alexey Makhov --- Sources/CLI/Registry/Login.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/CLI/Registry/Login.swift b/Sources/CLI/Registry/Login.swift index 617bc801..7de7fe7e 100644 --- a/Sources/CLI/Registry/Login.swift +++ b/Sources/CLI/Registry/Login.swift @@ -63,10 +63,18 @@ extension Application { let server = Reference.resolveDomain(domain: server) let scheme = try RequestScheme(registry.scheme).schemeFor(host: server) + let _url = "\(scheme)://\(server)" + guard let url = URL(string: _url) else { + throw ContainerizationError(.invalidArgument, message: "Cannot convert \(_url) to URL") + } + guard let host = url.host else { + throw ContainerizationError(.invalidArgument, message: "Invalid host \(server)") + } let client = RegistryClient( - host: server, + host: host, scheme: scheme.rawValue, + port: url.port, authentication: BasicAuthentication(username: username, password: password), retryOptions: .init( maxRetries: 10,