Skip to content

Commit d18d1a5

Browse files
committed
How to read env vars is also different on Windows
1 parent a22d4f8 commit d18d1a5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/k8s-tiller/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ resource "null_resource" "tiller_tls_ca_certs" {
274274
interpreter = local.is_windows ? ["PowerShell", "-Command"] : ["bash", "-c"]
275275

276276
command = <<-EOF
277-
${var.kubectl_server_endpoint != "" ? "echo \"$KUBECTL_CA_DATA\" > ${path.module}/kubernetes_server_ca.pem" : ""}
277+
${var.kubectl_server_endpoint != "" ? "echo \"${local.env_prefix}KUBECTL_CA_DATA\" > ${path.module}/kubernetes_server_ca.pem" : ""}
278278
${lookup(module.require_executables.executables, "kubectl", "")} ${local.esc_newl}
279279
${local.kubectl_auth_params} ${local.esc_newl}
280280
--namespace ${var.tiller_tls_ca_cert_secret_namespace} ${local.esc_newl}
@@ -330,7 +330,7 @@ resource "null_resource" "tiller_tls_certs" {
330330
interpreter = local.is_windows ? ["PowerShell", "-Command"] : ["bash", "-c"]
331331

332332
command = <<-EOF
333-
${var.kubectl_server_endpoint != "" ? "echo \"$KUBECTL_CA_DATA\" > ${path.module}/kubernetes_server_ca.pem" : ""}
333+
${var.kubectl_server_endpoint != "" ? "echo \"${local.env_prefix}KUBECTL_CA_DATA\" > ${path.module}/kubernetes_server_ca.pem" : ""}
334334
${lookup(module.require_executables.executables, "kubectl", "")} ${local.esc_newl}
335335
${local.kubectl_auth_params} ${local.esc_newl}
336336
--namespace ${var.namespace} ${local.esc_newl}
@@ -437,20 +437,21 @@ locals {
437437
tls_algorithm_config = var.private_key_algorithm == "ECDSA" ? "--tls-private-key-ecdsa-curve ${var.private_key_ecdsa_curve}" : "--tls-private-key-rsa-bits ${var.private_key_rsa_bits}"
438438

439439
kubergrunt_auth_params = <<-EOF
440-
${var.kubectl_server_endpoint != "" ? "--kubectl-server-endpoint \"$KUBECTL_SERVER_ENDPOINT\" --kubectl-certificate-authority \"$KUBECTL_CA_DATA\" --kubectl-token \"$KUBECTL_TOKEN\"" : ""} ${local.esc_newl}
440+
${var.kubectl_server_endpoint != "" ? "--kubectl-server-endpoint \"${local.env_prefix}KUBECTL_SERVER_ENDPOINT\" --kubectl-certificate-authority \"${local.env_prefix}KUBECTL_CA_DATA\" --kubectl-token \"{local.env_prefix}KUBECTL_TOKEN\"" : ""} ${local.esc_newl}
441441
${var.kubectl_config_path != "" ? "--kubeconfig ${var.kubectl_config_path}" : ""} ${local.esc_newl}
442442
${var.kubectl_config_context_name != "" ? "--kubectl-context-name ${var.kubectl_config_context_name}" : ""} ${local.esc_newl}
443443
EOF
444444

445445

446446
kubectl_auth_params = <<-EOF
447-
${var.kubectl_server_endpoint != "" ? "--server \"$KUBECTL_SERVER_ENDPOINT\" --certificate-authority \"${path.module}/kubernetes_server_ca.pem\" --token \"$KUBECTL_TOKEN\"" : ""} ${local.esc_newl}
447+
${var.kubectl_server_endpoint != "" ? "--server \"${local.env_prefix}KUBECTL_SERVER_ENDPOINT\" --certificate-authority \"${path.module}/kubernetes_server_ca.pem\" --token \"${local.env_prefix}KUBECTL_TOKEN\"" : ""} ${local.esc_newl}
448448
${var.kubectl_config_path != "" ? "--kubeconfig ${var.kubectl_config_path}" : ""} ${local.esc_newl}
449449
${var.kubectl_config_context_name != "" ? "--context ${var.kubectl_config_context_name}" : ""} ${local.esc_newl}
450450
EOF
451451

452452

453453
is_windows = module.os.name == "Windows"
454+
env_prefix = local.is_windows ? "$env:" : "$"
454455
esc_newl = local.is_windows ? "`" : "\\"
455456
}
456457

0 commit comments

Comments
 (0)