Skip to content

Commit

Permalink
deamon => daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
m-barthelemy committed Feb 2, 2023
1 parent 869ea27 commit 9faba85
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 || |
Expand Down Expand Up @@ -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
Expand All @@ -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()}
```

Expand All @@ -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()}
Expand Down Expand Up @@ -447,7 +447,7 @@ defer {try! docker.syncShutdown()}
<details>
<summary>Push an image</summary>

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)
Expand Down Expand Up @@ -615,7 +615,7 @@ defer {try! docker.syncShutdown()}
</details>

<details>
<summary>Make the Docker deamon to join an existing Swarm cluster</summary>
<summary>Make the Docker daemon to join an existing Swarm cluster</summary>

```swift
// This first client points to an existing Swarm cluster manager
Expand Down
14 changes: 7 additions & 7 deletions Sources/DockerSwift/APIs/DockerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,15 +30,15 @@ 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,
timeout: HTTPClient.Configuration.Timeout = .init(),
proxy: HTTPClient.Configuration.Proxy? = nil
) {

self.deamonURL = deamonURL
self.daemonURL = daemonURL
self.tlsConfig = tlsConfig
let clientConfig = HTTPClient.Configuration(
tlsConfiguration: tlsConfig,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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())
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Sources/DockerSwift/Models/System/SystemInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions Tests/DockerSwiftTests/Utils/DockerClient+Testable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
)*/
Expand Down

0 comments on commit 9faba85

Please sign in to comment.