Skip to content

Commit

Permalink
dynamic version
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Apr 18, 2025
1 parent 8e37115 commit c7d3d9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions requirements.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ terraform {
source = "hashicorp/kubernetes"
version = ">= 2.23.0"
}
null = {
source = "hashicorp/null"
version = ">= 3.2.1"
}
}
}
27 changes: 25 additions & 2 deletions version.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
resource "null_resource" "git_version" {
triggers = {
# Force this to run on every apply to get the latest tag value
always_run = timestamp()
}

provisioner "local-exec" {
command = "git describe --tags --abbrev=0 2>/dev/null || echo 'unknown' > ${path.module}/.git_tag"
on_failure = continue
}
}

resource "null_resource" "module_name" {
triggers = {
module_path = path.module
}

provisioner "local-exec" {
command = "basename $(pwd) > ${path.module}/.module_name"
on_failure = continue
}
}

locals {
module_name = "tfmod-istio"
module_version = "0.1.1"
module_name = fileexists("${path.module}/.module_name") ? trimspace(file("${path.module}/.module_name")) : "tfmod-istio"
module_version = fileexists("${path.module}/.git_tag") ? trimspace(file("${path.module}/.git_tag")) : "latest"
}

0 comments on commit c7d3d9a

Please sign in to comment.