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 4e45a23 commit 8ea70bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Common issues and solutions:
| <a name="provider_aws.eecr"></a> [aws.eecr](#provider\_aws.eecr) | ~> 5.14 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | ~> 2.11 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | ~> 2.23 |
| <a name="provider_null"></a> [null](#provider\_null) | ~> 3.2 |
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.6 |

## Modules
Expand All @@ -100,6 +101,8 @@ Common issues and solutions:
| [helm_release.keycloak](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.keycloak-db](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubernetes_namespace.keycloak](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
| [null_resource.git_version](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.module_name](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [random_uuid.user_secret](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) | resource |
| [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
| [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
Expand Down
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-keycloak"
module_version = "0.1.0"
module_name = fileexists("${path.module}/.module_name") ? trimspace(file("${path.module}/.module_name")) : "tfmod-keycloak"
module_version = fileexists("${path.module}/.git_tag") ? trimspace(file("${path.module}/.git_tag")) : "latest"
}

0 comments on commit 8ea70bb

Please sign in to comment.