Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/case-sensitive #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions examples/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module "labels" {
source = "./../"

enabled = true
name = "labels"
environment = "test"
label_order = ["name", "environment"]
attributes = ["private"]
enabled = true
case_sensitive = true
name = "labels"
environment = "test"
label_order = ["name", "environment"]
attributes = ["private"]
extra_tags = {
Application = "CloudDrove"
}
Expand Down
13 changes: 6 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ locals {

# run loop for label order and set in value.
id_labels = [for l in local.label_order : local.id_context[l] if length(local.id_context[l]) > 0 && var.enabled]
id = var.enabled ? lower(join(var.delimiter, local.id_labels, var.attributes)) : ""
name = var.enabled ? lower(format("%v", var.name)) : ""
environment = var.enabled ? lower(format("%v", var.environment)) : ""
managedby = var.enabled ? lower(format("%v", var.managedby)) : ""
repository = var.enabled ? lower(format("%v", var.repository)) : ""
attributes = var.enabled ? lower(format("%v", join(var.delimiter, compact(var.attributes)))) : ""

id = var.enabled ? (var.case_sensitive == true ? join(var.delimiter, local.id_labels, var.attributes) : lower(join(var.delimiter, local.id_labels, var.attributes))) : ""
name = var.enabled ? (var.case_sensitive == true ? format("%v", var.name) : lower(format("%v", var.name))) : ""
environment = var.enabled ? (var.case_sensitive == true ? format("%v", var.environment) : lower(format("%v", var.environment))) : ""
managedby = var.enabled ? (var.case_sensitive == true ? format("%v", var.managedby) : lower(format("%v", var.managedby))) : ""
repository = var.enabled ? (var.case_sensitive == true ? format("%v", var.repository) : lower(format("%v", var.repository))) : ""
attributes = var.enabled ? (var.case_sensitive == true ? format("%v", join(var.delimiter, compact(var.attributes))) : lower(format("%v", join(var.delimiter, compact(var.attributes))))) : ""
tags_context = {
# For AWS we need `Name` to be disambiguated sine it has a special meaning
name = local.id
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ variable "delimiter" {
default = "-"
description = "Delimiter to be used between `organization`, `name`, `environment` and `attributes`."
}

variable "case_sensitive" {
description = "Determines whether the environment variable should be case-sensitive"
type = bool
default = false
}