alexeyinkin commented on code in PR #25022:
URL: https://github.com/apache/beam/pull/25022#discussion_r1073260716


##########
playground/terraform/build.gradle.kts:
##########
@@ -295,7 +295,25 @@ tasks.register("prepareConfig") {
         val configFileName = "config.g.dart"
         val modulePath = 
project(":playground:frontend").projectDir.absolutePath
         var file = File("$modulePath/lib/$configFileName")
-
+        val lines = file.readLines()
+        val endOfSlice = lines.indexOfFirst { it.contains("Generated content 
below") }
+        if (endOfSlice != -1) {
+            val oldContent = lines.slice(0 until endOfSlice)
+            val flagDelete = file.delete()
+            if (!flagDelete) {
+                throw kotlin.RuntimeException("Deleting file failed")
+            }
+            val sb = kotlin.text.StringBuilder()
+            val lastLine = oldContent[oldContent.size - 1]
+            oldContent.forEach {
+                if (it == lastLine) {
+                    sb.append(it)
+                } else {
+                    sb.appendLine(it)
+                }
+            }
+            file.writeText(sb.toString())
+        }

Review Comment:
   I am not an expert in deployment. It `config.g.dart` already generated with 
Gradle, and this PR just allows this file to pre-exist under some conditions. 
Given that we are tired of copying `config.example.dart` to `config.g.dart` 
manually, I think this is worthy short-term.
   
   Mid-term I just want something clean and simple, idempotent with respect to 
command runs, and that will allow me any changes in the version-controlled 
copy. This currently is not idempotent and requires us to preserve a specific 
comment in the version-controlled copy.
   
   Whether we should merge this first or go directly with the mid-term goal is 
not up to me because I do not know the priorities in DevOps.
   
   I also think we also need a diagram of runs, like what starts what, because 
I am currently lost in this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to