Skip to content

Commit 96418c2

Browse files
committed
lint
1 parent f70dc6d commit 96418c2

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/ImdsResolvers.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package aws.sdk.kotlin.runtime.config.imds
27

38
import aws.sdk.kotlin.runtime.InternalSdkApi

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ExecuteCommandTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
import aws.sdk.kotlin.runtime.auth.credentials.executeCommand
27
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
38
import aws.smithy.kotlin.runtime.util.OsFamily

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTestResources.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package aws.sdk.kotlin.runtime.auth.credentials
27

38
// language=JSON

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/util/VerifyingInstanceMetadataProvider.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package aws.sdk.kotlin.runtime.util
27

38
import aws.sdk.kotlin.runtime.config.imds.InstanceMetadataProvider

aws-runtime/aws-config/mingw/src/aws/sdk/kotlin/runtime/auth/credentials/executeCommandMingw.kt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
*/
55
package aws.smithy.kotlin.runtime.client.util
66

7+
import aws.sdk.kotlin.runtime.util.SdkDispatchers // adjust import
78
import kotlinx.cinterop.*
89
import kotlinx.coroutines.withContext
9-
import aws.sdk.kotlin.runtime.util.SdkDispatchers // adjust import
10-
import platform.windows.*
1110
import platform.posix._wunlink // to delete the temp file afterwards
11+
import platform.windows.*
1212

1313
@OptIn(ExperimentalForeignApi::class)
1414
private fun String.wideCString(mem: MemScope) = wcstr.getPointer(mem)
@@ -20,7 +20,8 @@ internal actual suspend fun executeCommand(
2020
maxOutputLengthBytes: Long,
2121
timeoutMillis: Long,
2222
clock: Clock,
23-
): Pair<Int, String> = withContext(SdkDispatchers.IO) { memScoped {
23+
): Pair<Int, String> = withContext(SdkDispatchers.IO) {
24+
memScoped {
2425
// 1) Make a temp file to capture stdout+stderr
2526
val tmpDirBuf = allocArray<UShortVar>(MAX_PATH)
2627
val tmpNameBuf = allocArray<UShortVar>(MAX_PATH)
@@ -44,7 +45,7 @@ internal actual suspend fun executeCommand(
4445
sa.ptr,
4546
CREATE_ALWAYS,
4647
FILE_ATTRIBUTE_NORMAL.toUInt(),
47-
null
48+
null,
4849
)
4950
if (hOut == INVALID_HANDLE_VALUE) error("CreateFileW failed for temp output")
5051

@@ -53,7 +54,11 @@ internal actual suspend fun executeCommand(
5354
// Prefer %ComSpec% if present, else fallback.
5455
val comspecBuf = allocArray<WCHARVar>(MAX_PATH)
5556
val comspecLen = GetEnvironmentVariableW("ComSpec".wideCString(this), comspecBuf, MAX_PATH)
56-
val cmdExe = if (comspecLen > 0u) { comspecBuf } else { "C:\\Windows\\System32\\cmd.exe".wideCString(this) }
57+
val cmdExe = if (comspecLen > 0u) {
58+
comspecBuf
59+
} else {
60+
"C:\\Windows\\System32\\cmd.exe".wideCString(this)
61+
}
5762

5863
val cmdLine = (" /C " + command).wideCString(this)
5964

@@ -69,15 +74,15 @@ internal actual suspend fun executeCommand(
6974

7075
val created = CreateProcessW(
7176
cmdExe,
72-
cmdLine, // mutable buffer OK; wcstr gives writable copy here
77+
cmdLine, // mutable buffer OK; wcstr gives writable copy here
7378
null,
7479
null,
75-
TRUE, // inherit handles (so child gets hOut)
80+
TRUE, // inherit handles (so child gets hOut)
7681
CREATE_NO_WINDOW.toUInt(),
7782
null,
7883
null,
7984
si.ptr,
80-
pi.ptr
85+
pi.ptr,
8186
)
8287
if (created == 0) error("CreateProcessW failed: ${GetLastError()}")
8388

@@ -94,7 +99,6 @@ internal actual suspend fun executeCommand(
9499
error("Process timed out after ${timeoutMillis}ms")
95100
}
96101

97-
98102
// 5) Get exit code
99103
val exitCodeVar = alloc<DWORDVar>()
100104
GetExitCodeProcess(pi.hProcess, exitCodeVar.ptr)
@@ -109,7 +113,7 @@ internal actual suspend fun executeCommand(
109113
null,
110114
OPEN_EXISTING,
111115
FILE_ATTRIBUTE_NORMAL.toUInt(),
112-
null
116+
null,
113117
)
114118
if (hIn == INVALID_HANDLE_VALUE) {
115119
// Clean up and bail
@@ -151,4 +155,5 @@ internal actual suspend fun executeCommand(
151155
} finally {
152156
CloseHandle(hOut)
153157
}
154-
} }
158+
}
159+
}

0 commit comments

Comments
 (0)