From 62c6f1fa15a26a7127429258b51a93886391acd8 Mon Sep 17 00:00:00 2001 From: Steve McMaster Date: Sun, 21 Jul 2024 12:05:04 -0400 Subject: [PATCH] Reduce templates to those with matching container images --- .drone.star | 97 +++++++--------------------------------------------- _lang.tf.j2 | 31 +++-------------- splunk.tf.j2 | 1 + 3 files changed, 19 insertions(+), 110 deletions(-) diff --git a/.drone.star b/.drone.star index f7af4eb..b941a93 100644 --- a/.drone.star +++ b/.drone.star @@ -1,3 +1,11 @@ +ALPINE_VERSIONS = ("3.20", "edge") +JAVA_MAVEN_VERSIONS = ("21",) +JAVA_GRADLE_VERSIONS = ("8.3-jdk17",) +PYTHON_VERSIONS = ("3.12",) +RUST_VERSIONS = ("1.71",) +SPLUNK_VERSIONS = ("9.1", "9.2") +UBUNTU_VERSIONS = ("24.04",) + TEMPLATES = { "_distro": { "alpine": { @@ -5,7 +13,7 @@ TEMPLATES = { "distro_shortname": "alpine", "distro_icon": "https://s3.mcmaster.io/images/Alpine_Linux_logo.png", "distro_package_manager": "apk", - "distro_releases": ["3.17", "3.18", "3.19", "3.20", "edge"], + "distro_releases": ALPINE_VERSIONS, "image": "cr.smcm.xyz/coder-images/alpine", }, "aports": { @@ -17,118 +25,39 @@ TEMPLATES = { "image": "cr.smcm.xyz/coder-images/alpine", "startup_scripts": ["alpine_aports"], }, - # "gcloud-terraform": { - # "distro_name": "Ubuntu Linux", - # "distro_shortname": "ubuntu", - # "distro_icon": "/icon/ubuntu.svg", - # "distro_package_manager": "apt", - # "distro_releases": [], - # "image": "cr.smcm.xyz/coder-images/coder-devops", - # # "startup_scripts": ["gcloud", "terraform"], - # }, - # "ollama-quantize": { - # "distro_name": "Debian Linux", - # "distro_shortname": "debian", - # "distro_icon": "/icons/debian.svg", - # "distro_package_manager": "apt", - # "distro_releases": [], - # "image": "cr.smcm.xyz/coder-images/ollama:quantize", - # "coder_home_disk_size": "100", - # "startup_scripts": ["ollama"] - # }, "ubuntu": { "distro_name": "Ubuntu Linux", "distro_shortname": "ubuntu", "distro_icon": "/icon/ubuntu.svg", "distro_package_manager": "apt", - "distro_releases": ["20.04", "22.04", "23.04", "23.10", "24.04"], + "distro_releases": UBUNTU_VERSIONS, "image": "cr.smcm.xyz/coder-images/ubuntu", }, }, "_lang": { - "eclipse-temurin": { - "lang": "eclipse-temurin", - "lang_icon": "/icon/java.svg", - "versions": ["11-jdk", "17-jdk", "21-jdk"], - "distro_choices": [ - {"label": "Ubuntu Jammy", "suffix": "-jammy"}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], - }, - "golang": { - "lang": "golang", - "lang_icon": "/icon/go.svg", - "versions": ["1.21"], - "distro_choices": [ - {"label": "Debian Bookworm", "suffix": "-bookworm"}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], - }, "gradle": { "lang": "gradle", "lang_icon": "/icon/java.svg", - "versions": ["8.3-jdk17"], + "versions": JAVA_GRADLE_VERSIONS, "coder_user": "gradle", - "distro_choices": [ - {"label": "Debian", "suffix": ""}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], }, "maven": { "lang": "maven", "lang_icon": "/icon/java.svg", - "versions": ["11", "17", "21"], + "versions": JAVA_MAVEN_VERSIONS, "tag_prefix": "3-eclipse-temurin-", - "distro_choices": [ - {"label": "Ubuntu", "suffix": ""}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], - }, - "node": { - "lang": "node", - "lang_icon": "/icon/node.svg", - "versions": ["18", "20"], - "coder_user": "node", - "distro_choices": [ - {"label": "Debian Bookworm", "suffix": "-bookworm"}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], }, "python": { "lang": "python", "lang_icon": "/icon/python.svg", "versions": ["3.8", "3.11"], - "distro_choices": [ - {"label": "Debian Bookworm", "suffix": "-bookworm"}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], }, "rust": { "lang": "rust", "lang_icon": "/icon/rust.svg", - "versions": ["1.71"], - "distro_choices": [ - {"label": "Debian Bookworm", "suffix": "-bookworm"}, - {"label": "Alpine Linux", "suffix": "-alpine"}, - ], + "versions": RUST_VERSIONS, }, }, - # "android": { - # "android-2023-06": { - # "image": "cr.smcm.xyz/coder-images/android:2023.06", - # "coder_user": "circleci", - # "coder_user_uid": "1001", - # "coder_user_gid": "1002", - # "vs_code_root": "/home/circleci/project", - # }, - # }, - # "jupyter": { - # "jupyter-scipy-notebook": { - # "image": "cr.smcm.xyz/coder-images/jupyter:scipy-notebook", - # "coder_user": "jovyan", - # "coder_user_gid": "100", - # }, - # }, "splunk": { "splunk": { "image": "cr.smcm.xyz/coder-images/splunk", diff --git a/_lang.tf.j2 b/_lang.tf.j2 index 23f4f7f..2095122 100644 --- a/_lang.tf.j2 +++ b/_lang.tf.j2 @@ -4,6 +4,10 @@ {% set tag_prefix = "" %} {% endif %} +{% if tag_suffix is not defined %} +{% set tag_suffix = "" %} +{% endif %} + {% block parameters %} {{ super() }} @@ -17,10 +21,6 @@ data "coder_parameter" "version" { {% endif %} mutable = true - option { - name = "Latest" - value = "" - } {% for version in versions %} option { name = "{{ version }}" @@ -29,27 +29,6 @@ data "coder_parameter" "version" { {% endfor %} } -{% if distro_choices %} -data "coder_parameter" "container_base" { - name = "Container Base" - description = "Container Base" - type = "string" - default = "{{ distro_choices[0]["suffix"] }}" - mutable = false - {% for distro_choice in distro_choices %} - option { - name = "{{ distro_choice["label"] }}" - value = "{{ distro_choice["suffix"] }}" - } - {% endfor %} -} -{% endif %} -{% endblock %} - {% block kubernetes_pod_main_image %} -{% if distro_choices %} - image = "cr.smcm.xyz/coder-images/{{lang}}:{{tag_prefix}}${data.coder_parameter.version.value}${data.coder_parameter.container_base.value}" -{% else %} - image = "cr.smcm.xyz/coder-images/{{lang}}:{{tag_prefix}}${data.coder_parameter.version.value}" -{% endif %} + image = "cr.smcm.xyz/coder-images/{{lang}}:{{tag_prefix}}${data.coder_parameter.version.value}{{tag_suffix}}" {% endblock %} \ No newline at end of file diff --git a/splunk.tf.j2 b/splunk.tf.j2 index 664112c..6f45da4 100644 --- a/splunk.tf.j2 +++ b/splunk.tf.j2 @@ -69,6 +69,7 @@ resource "coder_script" "splunk_ansible" { script = <