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 a3bd46a commit 88f4bb7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ resource "kubernetes_manifest" "example_grafana_datasource" {
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.14.0 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.11.0 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.23.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.1 |

## Providers

Expand All @@ -69,6 +70,7 @@ resource "kubernetes_manifest" "example_grafana_datasource" {
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.94.1 |
| <a name="provider_aws.eecr"></a> [aws.eecr](#provider\_aws.eecr) | 5.94.1 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.17.0 |
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.3 |
| <a name="provider_terraform"></a> [terraform](#provider\_terraform) | n/a |

## Modules
Expand All @@ -84,6 +86,8 @@ resource "kubernetes_manifest" "example_grafana_datasource" {
| Name | Type |
|------|------|
| [helm_release.loki](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | 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 |
| [terraform_data.bucket_name_validator](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
Expand Down
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-loki"
module_version = "0.1.1"
module_name = fileexists("${path.module}/.module_name") ? trimspace(file("${path.module}/.module_name")) : "tfmod-loki"
module_version = fileexists("${path.module}/.git_tag") ? trimspace(file("${path.module}/.git_tag")) : "latest"
}

0 comments on commit 88f4bb7

Please sign in to comment.