in resources/repositories/cluster-mgmt.git/stages/Helmfile.groovy [66:88]
void placeCertificatesForKeycloak(context, String customDnsHost, String vaultPath) {
String vaultNamespace = "user-management"
String vaultUrl = "http://hashicorp-vault.user-management.svc.cluster.local:8200"
String vaultToken = (new String(context.platform.getJsonPathValue("secrets", "vault-root-token",
".data.VAULT_ROOT_TOKEN", vaultNamespace).decodeBase64()))
String keycloakChartPath = "/opt/repositories/components/infra/keycloak.git/deploy-templates"
String certificateFolderName = customDnsHost.replace(".","-")
def secretDataResponse = script.httpRequest url: vaultUrl + "/v1/" + vaultPath.replaceFirst('/', '/data/'),
httpMode: 'GET',
customHeaders: [[name: 'X-Vault-Token', value: "${vaultToken}"]],
validResponseCodes: '200,404',
quiet: true
if (secretDataResponse.status.equals(200)) {
def folder = new File("${keycloakChartPath}/certificates/${certificateFolderName}")
new JsonSlurperClassic().parseText(secretDataResponse.content).data.data.each { secretKey, secretValue ->
script.dir("${folder}") {
script.writeFile(file: secretKey, text: secretValue)
}
}
}
}