Skip to content

Commit 6dcb403

Browse files
authored
[RORDEV-1501] docker images issue with accepting consent (#1138)
1 parent 6f35530 commit 6dcb403

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
publishedPluginVersion=1.65.0
2-
pluginVersion=1.65.0
2+
pluginVersion=1.65.1
33
pluginName=readonlyrest
44

55
org.gradle.jvmargs=-Xmx6144m

ror-tools/src/main/scala/tech/beshu/ror/tools/RorToolsApp.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ trait RorTools {
6767
}
6868
}
6969

70-
private def readArgsFromEnvVariables()(implicit rawEnvVariablesProvider: RawEnvVariablesProvider): Array[String] = {
70+
private def readArgsFromEnvVariables()
71+
(implicit rawEnvVariablesProvider: RawEnvVariablesProvider): Array[String] = {
7172
val allowedEnvVariableNames = List(
7273
consentFlagName,
7374
)
7475
rawEnvVariablesProvider.getSysEnv.toList
7576
.filter(env => allowedEnvVariableNames.contains(env._1.toLowerCase))
76-
.flatMap { case (name, value) => Array(s"--$name", value) }
77+
.flatMap { case (name, value) => Array(s"--${name.toLowerCase}", value) }
7778
.toArray
7879
}
7980

@@ -192,6 +193,7 @@ trait RorTools {
192193
patchCommand,
193194
note(""),
194195
opt[String](consentFlagName)
196+
.unbounded()
195197
.valueName("<yes/no>")
196198
.validate {
197199
case "yes" => success
@@ -255,7 +257,6 @@ trait RorTools {
255257

256258
private def effectSetup(implicit inOut: InOut): OEffectSetup = new DefaultOEffectSetup {
257259
override def displayToOut(msg: String): Unit = inOut.println(msg)
258-
259260
override def displayToErr(msg: String): Unit = inOut.printlnErr(msg)
260261
}
261262

ror-tools/src/test/scala/tech/beshu/ror/tools/RorToolsAppSuite.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import tech.beshu.ror.tools.RorTools.Result
2828
import tech.beshu.ror.tools.core.patches.base.EsPatchMetadataCodec
2929
import tech.beshu.ror.tools.core.patches.internal.FilePatch.FilePatchMetadata
3030
import tech.beshu.ror.tools.core.patches.internal.RorPluginDirectory.EsPatchMetadata
31-
import tech.beshu.ror.tools.core.utils.{OsRawEnvVariablesProvider, RawEnvVariablesProvider, InOut}
31+
import tech.beshu.ror.tools.core.utils.{InOut, OsRawEnvVariablesProvider, RawEnvVariablesProvider}
3232
import tech.beshu.ror.tools.utils.{CapturingOutputAndMockingInput, ExampleEsWithRorContainer}
3333
import tech.beshu.ror.utils.files.FileUtils
3434

@@ -165,6 +165,18 @@ class RorToolsAppSuite
165165
|""".stripMargin
166166
)
167167
}
168+
"Patching not started when user declines to accept implications of patching (when env variable is set and arg is passed in the same time)" in {
169+
val (result, output) = captureResultAndOutput(
170+
RorToolsTestApp.run(Array("patch", "--I_UNDERSTAND_AND_ACCEPT_ES_PATCHING", "no"))(_, _),
171+
mockedEnvs = Map("I_UNDERSTAND_AND_ACCEPT_ES_PATCHING" -> "no")
172+
)
173+
result should equal(Result.Failure)
174+
output should equal(
175+
"""You have to confirm, that You understand the implications of ES patching in order to perform it.
176+
|You can read about patching in our documentation: https://docs.readonlyrest.com/elasticsearch#id-3.-patch-elasticsearch.
177+
|""".stripMargin
178+
)
179+
}
168180
"Patching not started when user declines to accept implications of patching (in interactive mode)" in {
169181
val (result, output) = captureResultAndOutputWithInteraction(
170182
RorToolsTestApp.run(Array("patch"))(_, _),
@@ -336,7 +348,6 @@ class RorToolsAppSuite
336348
.stripMargin
337349
)
338350
}
339-
340351
"The patch is not detected when metadata file is missing and `verify` command is executed" in {
341352
val (patchResult, patchOutput) = captureResultAndOutput {
342353
RorToolsTestApp.run(Array("patch", "--I_UNDERSTAND_AND_ACCEPT_ES_PATCHING", "yes", "--es-path", esLocalPath.toString))(_, _)
@@ -368,7 +379,6 @@ class RorToolsAppSuite
368379
|""".stripMargin
369380
)
370381
}
371-
372382
"The patch is not detected when metadata file is missing and `verify` command is executed (ES 9.x with detailed assertions)" excludeES(allEs6x, allEs7x, allEs8x) in {
373383
val (patchResult, patchOutput) = captureResultAndOutput {
374384
RorToolsTestApp.run(Array("patch", "--I_UNDERSTAND_AND_ACCEPT_ES_PATCHING", "yes", "--es-path", esLocalPath.toString))(_, _)

0 commit comments

Comments
 (0)