diff --git a/README.md b/README.md index bca4d30..1f9207e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This means that it will work with Docker >= 20.10. | | HTTP | ✅ | | | | HTTPS | ✅ | | | | | | | -| Docker deamon & System info | Ping | ✅ | | +| Docker daemon & System info | Ping | ✅ | | | | Info | ✅ | | | | Version | ✅ | | | | Events | ✅ | | @@ -158,7 +158,7 @@ Enter `https://github.com/m-barthelemy/DockerSwift.git` for the URL. ## Usage Examples -### Connect to a Docker deamon +### Connect to a Docker daemon Local socket (defaults to `/var/run/docker.sock`): ```swift @@ -172,7 +172,7 @@ Remote daemon over HTTP: ```swift import DockerSwift -let docker = DockerClient(deamonURL: .init(string: "http://127.0.0.1:2375")!) +let docker = DockerClient(daemonURL: .init(string: "http://127.0.0.1:2375")!) defer {try! docker.syncShutdown()} ``` @@ -187,7 +187,7 @@ tlsConfig.additionalTrustRoots.append(.file("docker-daemon-ca.pem")) tlsConfig.certificateVerification = .noHostnameVerification let docker = DockerClient( - deamonURL: .init(string: "https://your.docker.daemon:2376")!, + daemonURL: .init(string: "https://your.docker.daemon:2376")!, tlsConfig: tlsConfig ) defer {try! docker.syncShutdown()} @@ -447,7 +447,7 @@ defer {try! docker.syncShutdown()}
Push an image - Supposing that the Docker deamon has an image named "my-private-image:latest": + Supposing that the Docker daemon has an image named "my-private-image:latest": ```swift var credentials = RegistryAuth(username: "myUsername", password: "....") try await docker.registries.login(credentials: &credentials) @@ -615,7 +615,7 @@ defer {try! docker.syncShutdown()}
- Make the Docker deamon to join an existing Swarm cluster + Make the Docker daemon to join an existing Swarm cluster ```swift // This first client points to an existing Swarm cluster manager diff --git a/Sources/DockerSwift/APIs/DockerClient.swift b/Sources/DockerSwift/APIs/DockerClient.swift index 80d23ae..084ed38 100644 --- a/Sources/DockerSwift/APIs/DockerClient.swift +++ b/Sources/DockerSwift/APIs/DockerClient.swift @@ -15,7 +15,7 @@ public class DockerClient { ]) private let decoder: JSONDecoder - internal let deamonURL: URL + internal let daemonURL: URL internal let tlsConfig: TLSConfiguration? internal let client: HTTPClient private let logger: Logger @@ -30,7 +30,7 @@ public class DockerClient { /// - timeout: Pass custom connect and read timeouts via a `HTTPClient.Configuration.Timeout` instance /// - proxy: Proxy settings, defaults to `nil`. public init( - deamonURL: URL = URL(httpURLWithSocketPath: "/var/run/docker.sock")!, + daemonURL: URL = URL(httpURLWithSocketPath: "/var/run/docker.sock")!, tlsConfig: TLSConfiguration? = nil, logger: Logger = .init(label: "docker-client"), clientThreads: Int = 2, @@ -38,7 +38,7 @@ public class DockerClient { proxy: HTTPClient.Configuration.Proxy? = nil ) { - self.deamonURL = deamonURL + self.daemonURL = daemonURL self.tlsConfig = tlsConfig let clientConfig = HTTPClient.Configuration( tlsConfiguration: tlsConfig, @@ -88,7 +88,7 @@ public class DockerClient { } return try await client.execute( endpoint.method, - daemonURL: self.deamonURL, + daemonURL: self.daemonURL, urlPath: "/\(apiVersion)/\(endpoint.path)", body: endpoint.body.map {HTTPClient.Body.data( try! $0.encode())}, logger: logger, @@ -109,7 +109,7 @@ public class DockerClient { logger.debug("\(Self.self) execute PipelineEndpoint: \(endpoint.method) \(endpoint.path)") return try await client.execute( endpoint.method, - daemonURL: self.deamonURL, + daemonURL: self.daemonURL, urlPath: "/\(apiVersion)/\(endpoint.path)", body: endpoint.body.map {HTTPClient.Body.data( try! $0.encode())}, logger: logger, @@ -125,7 +125,7 @@ public class DockerClient { logger.debug("\(Self.self) execute StreamingEndpoint: \(endpoint.method) \(endpoint.path)") let stream = try await client.executeStream( endpoint.method, - daemonURL: self.deamonURL, + daemonURL: self.daemonURL, urlPath: "/\(apiVersion)/\(endpoint.path)", body: endpoint.body.map { HTTPClientRequest.Body.bytes( try! $0.encode()) @@ -144,7 +144,7 @@ public class DockerClient { logger.debug("\(Self.self) execute \(T.self): \(endpoint.path)") let stream = try await client.executeStream( endpoint.method, - daemonURL: self.deamonURL, + daemonURL: self.daemonURL, urlPath: "/\(apiVersion)/\(endpoint.path)", body: endpoint.body == nil ? nil : .bytes(endpoint.body!), timeout: timeout, diff --git a/Sources/DockerSwift/Endpoints/Containers/ContainerAttachEndpoint.swift b/Sources/DockerSwift/Endpoints/Containers/ContainerAttachEndpoint.swift index e4e7ec1..8358e58 100644 --- a/Sources/DockerSwift/Endpoints/Containers/ContainerAttachEndpoint.swift +++ b/Sources/DockerSwift/Endpoints/Containers/ContainerAttachEndpoint.swift @@ -62,7 +62,7 @@ final class ContainerAttachEndpoint { func connect() async throws -> ContainerAttach { let config = WebSocketClient.Configuration(tlsConfiguration: self.dockerClient.tlsConfig) - let scheme = self.dockerClient.deamonURL.scheme + let scheme = self.dockerClient.daemonURL.scheme guard scheme == "http" || scheme == "https" else { throw DockerError.unsupportedScheme("Attach only supports connecting to docker daemons via HTTP or HTTPS") } @@ -71,9 +71,9 @@ final class ContainerAttachEndpoint { Task { try await WebSocket.connect( scheme: scheme == "https" ? "wss" : "ws", - host: self.dockerClient.deamonURL.host ?? self.dockerClient.deamonURL.path, - port: self.dockerClient.deamonURL.port ?? (self.dockerClient.deamonURL.scheme == "https" ? 2376 : 2375), - path: "\(self.dockerClient.deamonURL.path)/\(self.dockerClient.apiVersion)/\(self.path)", + host: self.dockerClient.daemonURL.host ?? self.dockerClient.daemonURL.path, + port: self.dockerClient.daemonURL.port ?? (self.dockerClient.daemonURL.scheme == "https" ? 2376 : 2375), + path: "\(self.dockerClient.daemonURL.path)/\(self.dockerClient.apiVersion)/\(self.path)", query: self.query, headers: [:], configuration: config, diff --git a/Sources/DockerSwift/Models/System/SystemInformation.swift b/Sources/DockerSwift/Models/System/SystemInformation.swift index aeef5db..6f89ac2 100644 --- a/Sources/DockerSwift/Models/System/SystemInformation.swift +++ b/Sources/DockerSwift/Models/System/SystemInformation.swift @@ -129,7 +129,7 @@ public struct SystemInformation: Codable { /// Note: Containers do not automatically inherit this configuration. public let noProxy: String - /// Hostname of the host where the Docker deamon is running. + /// Hostname of the host where the Docker daemon is running. public let name: String public let labels: [String] diff --git a/Tests/DockerSwiftTests/Utils/DockerClient+Testable.swift b/Tests/DockerSwiftTests/Utils/DockerClient+Testable.swift index 092b310..a112fd3 100644 --- a/Tests/DockerSwiftTests/Utils/DockerClient+Testable.swift +++ b/Tests/DockerSwiftTests/Utils/DockerClient+Testable.swift @@ -14,7 +14,7 @@ extension DockerClient { return DockerClient(logger: logger) // Remote via simple HTTP - //return DockerClient(deamonURL: .init(string: "http://127.0.0.1:2375")!, logger: logger) + //return DockerClient(daemonURL: .init(string: "http://127.0.0.1:2375")!, logger: logger) // Remote daemon, using HTTPS and client certs authentication /*var tlsConfig = TLSConfiguration.makeClientConfiguration() @@ -23,7 +23,7 @@ extension DockerClient { tlsConfig.additionalTrustRoots.append(.file("ca-public.pem")) tlsConfig.certificateVerification = .noHostnameVerification return DockerClient( - deamonURL: .init(string: "https://51.15.19.7:2376")!, + daemonURL: .init(string: "https://51.15.19.7:2376")!, tlsConfig: tlsConfig, logger: logger )*/