Skip to content

Commit ab90a91

Browse files
author
Patrick Mirwald
committed
chore: run ktlinFormat
1 parent 0059c99 commit ab90a91

File tree

3 files changed

+64
-55
lines changed

3 files changed

+64
-55
lines changed

src/main/kotlin/com/liftric/code/artifact/repository/CodeArtifact.kt

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,75 +21,79 @@ abstract class CodeArtifact {
2121
abstract val secretAccessKey: Property<String>
2222

2323
private val stsClient by lazy {
24-
StsClient.builder().apply {
25-
region.orNull?.let {
26-
region(it)
27-
}
28-
if (accessKeyId.orNull != null && secretAccessKey.orNull != null) {
29-
credentialsProvider {
30-
StaticCredentialsProvider.create(
31-
AwsBasicCredentials.create(
32-
accessKeyId.get(),
33-
secretAccessKey.get(),
34-
),
35-
).resolveCredentials()
24+
StsClient
25+
.builder()
26+
.apply {
27+
region.orNull?.let {
28+
region(it)
3629
}
37-
} else {
38-
profile.orNull?.let {
30+
if (accessKeyId.orNull != null && secretAccessKey.orNull != null) {
3931
credentialsProvider {
40-
ProfileCredentialsProvider.create(profile.get()).resolveCredentials()
32+
StaticCredentialsProvider
33+
.create(
34+
AwsBasicCredentials.create(
35+
accessKeyId.get(),
36+
secretAccessKey.get(),
37+
),
38+
).resolveCredentials()
39+
}
40+
} else {
41+
profile.orNull?.let {
42+
credentialsProvider {
43+
ProfileCredentialsProvider.create(profile.get()).resolveCredentials()
44+
}
4145
}
4246
}
43-
}
44-
}.build()
47+
}.build()
4548
}
4649

4750
private val client by lazy {
48-
CodeartifactClient.builder().apply {
49-
region.orNull?.let {
50-
region(it)
51-
}
52-
if (accessKeyId.orNull != null && secretAccessKey.orNull != null) {
53-
credentialsProvider {
54-
StaticCredentialsProvider.create(
55-
AwsBasicCredentials.create(
56-
accessKeyId.get(),
57-
secretAccessKey.get(),
58-
),
59-
).resolveCredentials()
51+
CodeartifactClient
52+
.builder()
53+
.apply {
54+
region.orNull?.let {
55+
region(it)
6056
}
61-
} else {
62-
profile.orNull?.let {
57+
if (accessKeyId.orNull != null && secretAccessKey.orNull != null) {
6358
credentialsProvider {
64-
ProfileCredentialsProvider.create(profile.get()).resolveCredentials()
59+
StaticCredentialsProvider
60+
.create(
61+
AwsBasicCredentials.create(
62+
accessKeyId.get(),
63+
secretAccessKey.get(),
64+
),
65+
).resolveCredentials()
66+
}
67+
} else {
68+
profile.orNull?.let {
69+
credentialsProvider {
70+
ProfileCredentialsProvider.create(profile.get()).resolveCredentials()
71+
}
6572
}
6673
}
67-
}
68-
}.build()
74+
}.build()
6975
}
7076

7177
private val accountId by lazy {
7278
stsClient.getCallerIdentity {}.account()
7379
}
7480

75-
internal fun authorizationTokenResponse(domain: String): GetAuthorizationTokenResponse {
76-
return client.getAuthorizationToken {
81+
internal fun authorizationTokenResponse(domain: String): GetAuthorizationTokenResponse =
82+
client.getAuthorizationToken {
7783
it.domain(domain)
7884
it.domainOwner(accountId)
7985
it.durationSeconds(tokenExpiresIn.getOrElse(1_800))
8086
}
81-
}
8287

8388
internal fun repositoryEndpointResponse(
8489
domain: String,
8590
repository: String,
8691
format: String = "maven",
87-
): GetRepositoryEndpointResponse {
88-
return client.getRepositoryEndpoint {
92+
): GetRepositoryEndpointResponse =
93+
client.getRepositoryEndpoint {
8994
it.domain(domain)
9095
it.domainOwner(accountId)
9196
it.repository(repository)
9297
it.format(format)
9398
}
94-
}
9599
}

src/main/kotlin/com/liftric/code/artifact/repository/CodeArtifactRepositoryExtension.kt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@ package com.liftric.code.artifact.repository
22

33
import org.gradle.api.plugins.ExtensionContainer
44

5-
abstract class CodeArtifactRepositoryExtension(private val extensionContainer: ExtensionContainer) : CodeArtifact() {
5+
abstract class CodeArtifactRepositoryExtension(
6+
private val extensionContainer: ExtensionContainer,
7+
) : CodeArtifact() {
68
fun additional(
79
name: String,
810
block: CodeArtifact.() -> Unit,
911
) {
1012
if (name.isEmpty()) error("Empty domain is not supported!")
1113
store[name] =
12-
extensionContainer.create(
13-
"${name}${CodeArtifactRepositoryPlugin.EXTENSION_NAME}",
14-
CodeArtifactRepositoryExtension::class.java,
15-
extensionContainer,
16-
).apply {
17-
block.invoke(this)
18-
region.convention(this@CodeArtifactRepositoryExtension.region)
19-
profile.convention(this@CodeArtifactRepositoryExtension.profile)
20-
accessKeyId.convention(this@CodeArtifactRepositoryExtension.accessKeyId)
21-
secretAccessKey.convention(this@CodeArtifactRepositoryExtension.secretAccessKey)
22-
tokenExpiresIn.convention(this@CodeArtifactRepositoryExtension.tokenExpiresIn)
23-
}
14+
extensionContainer
15+
.create(
16+
"${name}${CodeArtifactRepositoryPlugin.EXTENSION_NAME}",
17+
CodeArtifactRepositoryExtension::class.java,
18+
extensionContainer,
19+
).apply {
20+
block.invoke(this)
21+
region.convention(this@CodeArtifactRepositoryExtension.region)
22+
profile.convention(this@CodeArtifactRepositoryExtension.profile)
23+
accessKeyId.convention(this@CodeArtifactRepositoryExtension.accessKeyId)
24+
secretAccessKey.convention(this@CodeArtifactRepositoryExtension.secretAccessKey)
25+
tokenExpiresIn.convention(this@CodeArtifactRepositoryExtension.tokenExpiresIn)
26+
}
2427
}
2528

2629
companion object {

src/main/kotlin/com/liftric/code/artifact/repository/CodeArtifactRepositoryPlugin.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ abstract class CodeArtifactRepositoryPlugin : Plugin<Any> {
1717
override fun apply(scope: Any) {
1818
when (scope) {
1919
is Settings -> {
20-
scope.extensions.create(EXTENSION_NAME, CodeArtifactRepositoryExtension::class.java, scope.extensions)
20+
scope.extensions
21+
.create(EXTENSION_NAME, CodeArtifactRepositoryExtension::class.java, scope.extensions)
2122
.also {
2223
CodeArtifactRepositoryExtension.store[""] = it
2324
}
2425
}
2526

2627
is Project -> {
27-
scope.extensions.create(EXTENSION_NAME, CodeArtifactRepositoryExtension::class.java, scope.extensions)
28+
scope.extensions
29+
.create(EXTENSION_NAME, CodeArtifactRepositoryExtension::class.java, scope.extensions)
2830
.also {
2931
CodeArtifactRepositoryExtension.store[""] = it
3032
}

0 commit comments

Comments
 (0)