damondouglas commented on code in PR #23208:
URL: https://github.com/apache/beam/pull/23208#discussion_r991489563
##########
playground/terraform/build.gradle.kts:
##########
@@ -395,3 +372,111 @@ task("deployBackend") {
dependsOn(deploy)
}
+task("takeConfig") {
+ group = "deploy"
+ doLast {
+ var ipaddr = ""
+ var redis = ""
+ var proj = ""
+ var registry = ""
+ var ipaddrname = ""
+ var d_tag = ""
+ var stdout = ByteArrayOutputStream()
+ if (project.hasProperty("docker-tag")) {
+ d_tag = project.property("docker-tag") as String
+ }
+ exec {
+ commandLine = listOf("terraform", "output",
"playground_static_ip_address")
+ standardOutput = stdout
+ }
+ ipaddr = stdout.toString().trim().replace("\"", "")
+ stdout = ByteArrayOutputStream()
+
+ exec {
+ commandLine = listOf("terraform", "output", "playground_redis_ip")
+ standardOutput = stdout
+ }
+ redis = stdout.toString().trim().replace("\"", "")
+ stdout = ByteArrayOutputStream()
+ exec {
+ commandLine = listOf("terraform", "output", "playground_gke_project")
+ standardOutput = stdout
+ }
+ proj = stdout.toString().trim().replace("\"", "")
+ stdout = ByteArrayOutputStream()
+ exec {
+ commandLine = listOf("terraform", "output", "docker-repository-root")
+ standardOutput = stdout
+ }
+ registry = stdout.toString().trim().replace("\"", "")
+ stdout = ByteArrayOutputStream()
+ exec {
+ commandLine = listOf("terraform", "output",
"playground_static_ip_address_name")
+ standardOutput = stdout
+ }
+ ipaddrname = stdout.toString().trim().replace("\"", "")
+ stdout = ByteArrayOutputStream()
+
+ val configFileName = "values.yaml"
+ val modulePath = project(":playground").projectDir.absolutePath
+ val file = File("$modulePath/infrastructure/helm-backend/$configFileName")
+ val lines = file.readLines()
+ val endOfSlice = lines.indexOfFirst { it.contains("static_ip") }
+ 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())
+ }
+ file.appendText("""
+static_ip: ${ipaddr}
+redis_ip: ${redis}:6379
+project_id: ${proj}
+registry: ${registry}
+static_ip_name: ${ipaddrname}
+tag: $d_tag
+ """)
+ }
+}
+helm {
+ val backend by charts.creating {
+ chartName.set("backend")
+ sourceDir.set(file("../infrastructure/helm-backend"))
+ }
+ releases {
+ create("backend") {
+ from(backend)
+ }
+ }
+}
+task ("gkebackend") {
+ group = "deploy"
+ val init = tasks.getByName("terraformInit")
+ val apply = tasks.getByName("terraformApplyInf")
+ val takeConfig = tasks.getByName("takeConfig")
+ val push = tasks.getByName("pushBack")
+ val helm = tasks.getByName("helmInstallBackend")
+ val prepare = tasks.getByName("prepareConfig")
+ dependsOn(init)
+ dependsOn(apply)
+ dependsOn(takeConfig)
+ dependsOn(push)
+ dependsOn(helm)
+ dependsOn(prepare)
+ apply.mustRunAfter(init)
+ takeConfig.mustRunAfter(apply)
+ push.mustRunAfter(takeConfig)
+ helm.mustRunAfter(push)
Review Comment:
May we consider
https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/helm?
The helm provider is one of the community supported and doesn't come with the
same support as the
https://cloud.google.com/build/docs/cloud-builders#supported_builder_images_provided_by?
Alternatively, there is
https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/gke-deploy
instead that provides the same variable substitution goals as helm. An example
is
https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/gke-deploy/doc/app/cloudbuild-with-configs.yaml#L29-L38
--
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]