Skip to content

Commit dc78ad8

Browse files
committed
Ref #34842: allow decimal value in memory for docker
1 parent 3b08910 commit dc78ad8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/main/kotlin/eu/openanalytics/shinyproxyoperator/impl/docker/DockerOrchestrator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,18 +496,18 @@ class DockerOrchestrator(channel: Channel<ShinyProxyEvent>,
496496

497497
private fun memoryToBytes(memory: String?): Long? {
498498
if (memory.isNullOrEmpty()) return null
499-
val matcher = Pattern.compile("(\\d+)([bkmg]?)i?").matcher(memory.lowercase(Locale.getDefault()))
499+
val matcher = Pattern.compile("(\\d+\\.?\\d*)([bkmg]?)i?").matcher(memory.lowercase(Locale.getDefault()))
500500
if (!matcher.matches()) {
501501
throw IllegalArgumentException("Invalid memory argument: $memory")
502502
}
503-
val mem = matcher.group(1).toLong()
503+
val mem = matcher.group(1).toDouble()
504504
val unit = matcher.group(2)
505505
return when (unit) {
506506
"k" -> mem * 1024
507507
"m" -> mem * (1024 * 1024).toLong()
508508
"g" -> mem * (1024 * 1024 * 1024).toLong()
509509
else -> throw IllegalArgumentException("Invalid memory argument: $memory")
510-
}
510+
}.toLong()
511511
}
512512

513513
private fun getCpuQuota(cpuPeriod: Long, cpu: String): Long {

0 commit comments

Comments
 (0)