Skip to content

Commit e18f31a

Browse files
authored
Merge pull request #94 from RADAR-base/release-1.2.1
Release 1.2.1
2 parents 6b57a46 + a8e1ecf commit e18f31a

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ When upgrading to version 0.6.0 from version 0.5.x or earlier, please follow the
7070
This package is available as docker image [`radarbase/radar-output-restructure`](https://hub.docker.com/r/radarbase/radar-output-restructure). The entrypoint of the image is the current application. So in all the commands listed in usage, replace `radar-output-restructure` with for example:
7171

7272
```shell
73-
docker run --rm -t --network hadoop -v "$PWD/output:/output" radarbase/radar-output-restructure:1.2.0 -n hdfs-namenode -o /output /myTopic
73+
docker run --rm -t --network hadoop -v "$PWD/output:/output" radarbase/radar-output-restructure:1.2.1 -n hdfs-namenode -o /output /myTopic
7474
```
7575

7676
## Command line usage
@@ -192,7 +192,7 @@ This package requires at least Java JDK 8. Build the distribution with
192192
and install the package into `/usr/local` with for example
193193
```shell
194194
sudo mkdir -p /usr/local
195-
sudo tar -xzf build/distributions/radar-output-restructure-1.2.0.tar.gz -C /usr/local --strip-components=1
195+
sudo tar -xzf build/distributions/radar-output-restructure-1.2.1.tar.gz -C /usr/local --strip-components=1
196196
```
197197

198198
Now the `radar-output-restructure` command should be available.

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
}
1717

1818
group = "org.radarbase"
19-
version = "1.2.0"
19+
version = "1.2.1"
2020

2121
description = "RADAR-base output restructuring"
2222
val website = "https://radar-base.org"

src/main/java/org/radarbase/output/config/RestructureConfig.kt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.azure.storage.blob.BlobServiceClientBuilder
66
import com.azure.storage.common.StorageSharedKeyCredential
77
import com.fasterxml.jackson.annotation.JsonIgnore
88
import io.minio.MinioClient
9+
import io.minio.credentials.IamAwsProvider
910
import org.apache.hadoop.conf.Configuration
1011
import org.radarbase.output.Application.Companion.CACHE_SIZE_DEFAULT
1112
import org.radarbase.output.Plugin
@@ -305,12 +306,12 @@ data class ResourceConfig(
305306
val local: LocalConfig? = null,
306307
val azure: AzureConfig? = null,
307308
) {
308-
@JsonIgnore
309-
lateinit var sourceType: ResourceType
309+
@get:JsonIgnore
310+
val sourceType: ResourceType by lazy {
311+
requireNotNull(type.toResourceType()) { "Unknown resource type $type, choose s3, hdfs or local" }
312+
}
310313

311314
fun validate() {
312-
sourceType = type.toResourceType()
313-
314315
when (sourceType) {
315316
ResourceType.S3 -> checkNotNull(s3) { "No S3 configuration provided." }
316317
ResourceType.HDFS -> checkNotNull(hdfs) { "No HDFS configuration provided." }.also { it.validate() }
@@ -336,7 +337,7 @@ fun String.toResourceType() = when(toLowerCase()) {
336337
"hdfs" -> ResourceType.HDFS
337338
"local" -> ResourceType.LOCAL
338339
"azure" -> ResourceType.AZURE
339-
else -> throw IllegalStateException("Unknown resource type $this, choose s3, hdfs or local")
340+
else -> null
340341
}
341342

342343
data class LocalConfig(
@@ -350,18 +351,23 @@ data class S3Config(
350351
/** URL to reach object store at. */
351352
val endpoint: String,
352353
/** Access token for writing data with. */
353-
val accessToken: String,
354+
val accessToken: String?,
354355
/** Secret key belonging to access token. */
355-
val secretKey: String,
356+
val secretKey: String?,
356357
/** Bucket name. */
357358
val bucket: String,
358359
/** If no endOffset is in the filename, read it from object tags. */
359360
val endOffsetFromTags: Boolean = false,
360361
) {
361-
fun createS3Client(): MinioClient = MinioClient.Builder()
362-
.endpoint(endpoint)
363-
.credentials(accessToken, secretKey)
364-
.build()
362+
363+
fun createS3Client(): MinioClient = MinioClient.Builder().apply {
364+
endpoint(endpoint)
365+
if (accessToken.isNullOrBlank() || secretKey.isNullOrBlank()) {
366+
credentialsProvider(IamAwsProvider(null, null))
367+
} else {
368+
credentials(accessToken, secretKey)
369+
}
370+
}.build()
365371

366372
fun withEnv(prefix: String): S3Config = this
367373
.copyEnv("${prefix}S3_ACCESS_TOKEN") { copy(accessToken = it) }

0 commit comments

Comments
 (0)