Skip to content

Commit 2c608e1

Browse files
committed
Lint codebase & api dump
1 parent 8125eec commit 2c608e1

File tree

65 files changed

+1020
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1020
-752
lines changed

api/yoki.api

Lines changed: 42 additions & 35 deletions
Large diffs are not rendered by default.

src/commonMain/kotlin/me/devnatan/yoki/Yoki.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import me.devnatan.yoki.resource.system.SystemResource
1212
import me.devnatan.yoki.resource.volume.VolumeResource
1313

1414
public expect class Yoki(config: YokiConfig) : CoroutineScope {
15-
1615
public val config: YokiConfig
1716
public val json: Json
1817
public val httpClient: HttpClient

src/commonMain/kotlin/me/devnatan/yoki/YokiConfig.kt

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public class YokiConfig(
2222
public val apiVersion: String,
2323
public val debugHttpCalls: Boolean,
2424
) {
25-
2625
init {
2726
check(socketPath.isNotBlank()) { "Socket path must be provided and cannot be blank" }
2827
check(apiVersion.isNotBlank()) { "Docker Remote API version must be provided and cannot be blank" }
@@ -38,7 +37,6 @@ public class YokiConfig(
3837
* Mutable builder for Yoki configuration.
3938
*/
4039
public class YokiConfigBuilder {
41-
4240
/**
4341
* Docker socket file used to communicate with main Docker daemon.
4442
*/
@@ -47,11 +45,12 @@ public class YokiConfigBuilder {
4745
/**
4846
* The version of the Docker API that will be used during communication.
4947
*/
50-
private var apiVersion: String = envOrFallback(
51-
key = DOCKER_API_VERSION_ENV_KEY,
52-
fallback = DEFAULT_DOCKER_API_VERSION,
53-
prefix = null,
54-
)
48+
private var apiVersion: String =
49+
envOrFallback(
50+
key = DOCKER_API_VERSION_ENV_KEY,
51+
fallback = DEFAULT_DOCKER_API_VERSION,
52+
prefix = null,
53+
)
5554

5655
/**
5756
* Whether to debug the HTTP calls to the Docker daemon.
@@ -95,11 +94,12 @@ public class YokiConfigBuilder {
9594
* have the [UNIX_SOCKET_PREFIX] on its prefix.
9695
*/
9796
public fun useUnixDefaults(): YokiConfigBuilder {
98-
socketPath = envOrFallback(
99-
key = DOCKER_HOST_ENV_KEY,
100-
fallback = DEFAULT_DOCKER_UNIX_SOCKET,
101-
prefix = UNIX_SOCKET_PREFIX,
102-
)
97+
socketPath =
98+
envOrFallback(
99+
key = DOCKER_HOST_ENV_KEY,
100+
fallback = DEFAULT_DOCKER_UNIX_SOCKET,
101+
prefix = UNIX_SOCKET_PREFIX,
102+
)
103103
return this
104104
}
105105

@@ -110,11 +110,12 @@ public class YokiConfigBuilder {
110110
* have the [HTTP_SOCKET_PREFIX] on its prefix.
111111
*/
112112
public fun useHttpDefaults(): YokiConfigBuilder {
113-
socketPath = envOrFallback(
114-
key = DOCKER_HOST_ENV_KEY,
115-
fallback = DEFAULT_DOCKER_HTTP_SOCKET,
116-
prefix = HTTP_SOCKET_PREFIX,
117-
)
113+
socketPath =
114+
envOrFallback(
115+
key = DOCKER_HOST_ENV_KEY,
116+
fallback = DEFAULT_DOCKER_HTTP_SOCKET,
117+
prefix = HTTP_SOCKET_PREFIX,
118+
)
118119
return this
119120
}
120121

@@ -123,11 +124,12 @@ public class YokiConfigBuilder {
123124
* See [selectDockerSocketPath] for implementation details.
124125
*/
125126
public fun forCurrentPlatform(): YokiConfigBuilder {
126-
socketPath = envOrFallback(
127-
key = DOCKER_HOST_ENV_KEY,
128-
fallback = selectDockerSocketPath(),
129-
prefix = null,
130-
)
127+
socketPath =
128+
envOrFallback(
129+
key = DOCKER_HOST_ENV_KEY,
130+
fallback = selectDockerSocketPath(),
131+
prefix = null,
132+
)
131133
return this
132134
}
133135

src/commonMain/kotlin/me/devnatan/yoki/YokiFactory.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import kotlin.jvm.JvmSynthetic
1111
*
1212
* @param configure The client configuration.
1313
*/
14-
public inline fun Yoki(crossinline configure: YokiConfigBuilder.() -> Unit): Yoki = Yoki(
15-
YokiConfigBuilder()
16-
.forCurrentPlatform()
17-
.apply(configure)
18-
.build(),
19-
)
14+
public inline fun Yoki(crossinline configure: YokiConfigBuilder.() -> Unit): Yoki =
15+
Yoki(
16+
YokiConfigBuilder()
17+
.forCurrentPlatform()
18+
.apply(configure)
19+
.build(),
20+
)

src/commonMain/kotlin/me/devnatan/yoki/io/Http.kt

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ internal fun createHttpClient(client: Yoki): HttpClient {
5454
val exceptionResponse = responseException.response
5555
println("exceptionResponse = ${exceptionResponse.body<String>()}")
5656

57-
val errorMessage = runCatching {
58-
exceptionResponse.body<GenericDockerErrorResponse>()
59-
}.getOrNull()?.message
57+
val errorMessage =
58+
runCatching {
59+
exceptionResponse.body<GenericDockerErrorResponse>()
60+
}.getOrNull()?.message
6061
throw YokiResponseException(
6162
cause = exception,
6263
message = errorMessage,
@@ -81,29 +82,34 @@ internal fun createHttpClient(client: Yoki): HttpClient {
8182
}
8283

8384
@OptIn(ExperimentalStdlibApi::class)
84-
private fun createUrlBuilder(socketPath: String): URLBuilder = if (isUnixSocket(socketPath)) {
85-
URLBuilder(
86-
protocol = URLProtocol.HTTP,
87-
port = DOCKER_SOCKET_PORT,
88-
host = socketPath.substringAfter(UNIX_SOCKET_PREFIX).encodeToByteArray().toHexString() + ENCODED_HOSTNAME_SUFFIX,
89-
)
90-
} else {
91-
val url = Url(socketPath)
92-
URLBuilder(
93-
protocol = URLProtocol.HTTP,
94-
host = url.host,
95-
port = url.port,
96-
)
97-
}
85+
private fun createUrlBuilder(socketPath: String): URLBuilder =
86+
if (isUnixSocket(socketPath)) {
87+
URLBuilder(
88+
protocol = URLProtocol.HTTP,
89+
port = DOCKER_SOCKET_PORT,
90+
host = socketPath.substringAfter(UNIX_SOCKET_PREFIX).encodeToByteArray().toHexString() + ENCODED_HOSTNAME_SUFFIX,
91+
)
92+
} else {
93+
val url = Url(socketPath)
94+
URLBuilder(
95+
protocol = URLProtocol.HTTP,
96+
host = url.host,
97+
port = url.port,
98+
)
99+
}
98100

99-
internal fun handleHttpFailure(exception: Throwable, statuses: Map<HttpStatusCode, (YokiResponseException) -> Throwable>) {
101+
internal fun handleHttpFailure(
102+
exception: Throwable,
103+
statuses: Map<HttpStatusCode, (YokiResponseException) -> Throwable>,
104+
) {
100105
if (exception !is YokiResponseException) {
101106
throw exception
102107
}
103108

104-
val resourceException = statuses.entries.firstOrNull { (code, _) ->
105-
code == exception.statusCode
106-
}?.value
109+
val resourceException =
110+
statuses.entries.firstOrNull { (code, _) ->
111+
code == exception.statusCode
112+
}?.value
107113

108114
throw resourceException
109115
?.invoke(exception)

src/commonMain/kotlin/me/devnatan/yoki/models/ExposedPort.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public data class ExposedPort internal constructor(
2828
val port = portAndProtocol.getOrNull(0)?.toUShortOrNull() ?: error("Invalid exposed port")
2929

3030
val protocolString = portAndProtocol.getOrNull(1) ?: error("Invalid exposed port")
31-
val protocol = runCatching { ExposedPortProtocol.valueOf(protocolString.uppercase()) }
32-
.getOrElse { error("Invalid exposed port") }
31+
val protocol =
32+
runCatching { ExposedPortProtocol.valueOf(protocolString.uppercase()) }
33+
.getOrElse { error("Invalid exposed port") }
3334

3435
return ExposedPort(port, protocol)
3536
}
@@ -49,12 +50,12 @@ public enum class ExposedPortProtocol {
4950
}
5051

5152
internal object ExposedPortSerializer : KSerializer<ExposedPort> {
52-
5353
override val descriptor: SerialDescriptor
54-
get() = buildClassSerialDescriptor("ExposedPort") {
55-
element("port", UShort.serializer().descriptor)
56-
element("protocol", ExposedPortProtocol.serializer().descriptor)
57-
}
54+
get() =
55+
buildClassSerialDescriptor("ExposedPort") {
56+
element("port", UShort.serializer().descriptor)
57+
element("protocol", ExposedPortProtocol.serializer().descriptor)
58+
}
5859

5960
override fun deserialize(decoder: Decoder): ExposedPort {
6061
try {
@@ -64,7 +65,10 @@ internal object ExposedPortSerializer : KSerializer<ExposedPort> {
6465
}
6566
}
6667

67-
override fun serialize(encoder: Encoder, value: ExposedPort) {
68+
override fun serialize(
69+
encoder: Encoder,
70+
value: ExposedPort,
71+
) {
6872
encoder.encodeString(value.toString())
6973
}
7074
}

src/commonMain/kotlin/me/devnatan/yoki/models/Healthcheck.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public data class HealthcheckResult internal constructor(
1919
@SerialName("ExitCode") public val exitCode: Int? = null,
2020
@SerialName("Output") public val output: String? = null,
2121
) {
22-
2322
public val startedAt: Instant by lazy { Instant.parse(startedAtString) }
2423
public val endedAt: Instant? by lazy { endedAtString?.let(Instant::parse) }
2524
}

0 commit comments

Comments
 (0)