Skip to content

Commit

Permalink
adding some outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jerowe committed Dec 12, 2021
1 parent 1fd4ba9 commit 7416940
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
13 changes: 12 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
resource "random_string" "computed_values" {
count = length(var.helm_release_merged_values_file) == 0 ? 1 : 0
length = 10
special = false
lower = true
upper = false
override_special = ""
}

locals {
helm_values_files = var.helm_values_files
helm_release_merged_values_file = length(var.helm_release_merged_values_file) == 0 ? abspath("${var.helm_values_dir}/computed-${random_string.computed_values[0].result}-values.yaml") : var.helm_release_merged_values_file
}

resource "null_resource" "merge_yamls" {
Expand All @@ -8,13 +18,14 @@ resource "null_resource" "merge_yamls" {
}
provisioner "local-exec" {
command = <<EOT
touch ${local.helm_release_merged_values_file}
chmod 777 *py
mkdir -p ${var.helm_values_dir}
python ${path.module}/merge_yamls.py --yaml-files \
%{for value_file in local.helm_values_files~}
${value_file} \
%{endfor~}
--output ${var.helm_release_merged_values_file}
--output ${local.helm_release_merged_values_file}
EOT
}
}
6 changes: 5 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ output "merge_helm_values_files_command" {
%{for value_file in local.helm_values_files~}
${value_file} \
%{endfor~}
--output ${var.helm_release_merged_values_file}
--output ${local.helm_release_merged_values_file}
EOT
}

output "helm_release_merged_values_file" {
value = local.helm_release_merged_values_file
}
3 changes: 2 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ variable "helm_values_dir" {

variable "helm_release_merged_values_file" {
type = string
description = "Path to merged helm files. This path must exist before the module is invoked."
description = "Path to merged helm files. If none is supplied one will be created for you."
default = ""
}

0 comments on commit 7416940

Please sign in to comment.