From 8be23b96e8bd845b1ce75057ed367094f0bc6c31 Mon Sep 17 00:00:00 2001 From: Steve McMaster Date: Thu, 12 Oct 2023 21:45:47 -0400 Subject: [PATCH] update --- .drone.star | 6 ++++++ base.tf.jinja | 5 +++++ terraform.tf.jinja | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 terraform.tf.jinja diff --git a/.drone.star b/.drone.star index 020d490..78b96e0 100644 --- a/.drone.star +++ b/.drone.star @@ -64,6 +64,12 @@ TEMPLATES = { "vs_code_root": "/opt/splunk" }, }, + "terraform": { + "terraform": { + "image": "cr.smcm.xyz/coder-images/terraform", + "terraform_versions": ["1.6"], + }, + }, "ubuntu": { "ubuntu": { "image": "cr.smcm.xyz/coder-images/ubuntu", diff --git a/base.tf.jinja b/base.tf.jinja index d5ddbc0..d704382 100644 --- a/base.tf.jinja +++ b/base.tf.jinja @@ -33,6 +33,10 @@ terraform { {% set vs_code_root = coder_user_home %} {% endif %} +{% if image_pull_policy is not defined %} +{% set image_pull_policy = "Always" %} +{% endif %} + locals { {% block locals %} {% endblock %} @@ -305,6 +309,7 @@ resource "kubernetes_deployment" "main" { {% block kubernetes_pod_main_command %} command = ["bash", "-c", coder_agent.main.init_script] {% endblock %} + image_pull_policy = {{ image_pull_policy }} {% block kubernetes_pod_main_container_security_context %} security_context { diff --git a/terraform.tf.jinja b/terraform.tf.jinja new file mode 100644 index 0000000..2ae2f3b --- /dev/null +++ b/terraform.tf.jinja @@ -0,0 +1,28 @@ +{% extends "base.tf.jinja" %} + +{% block parameters %} +{{ super() }} + +data "coder_parameter" "terraform_version" { + name = "Terraform Version" + description = "Terraform Version" + type = "string" + default = "" + + mutable = true + option { + name = "Latest" + value = "" + } + {% for version in terraform_versions %} + option { + name = "{{ version }}" + value = "-{{ version }}" + } + {% endfor %} +} +{% endblock %} + +{% block kubernetes_pod_main_image %} + image = "{{image}}${data.coder_parameter.terraform_version.value}:latest" +{% endblock %} \ No newline at end of file