osinfra-io / google-cloud-kubernetes

Infrastructure as Code (IaC) example for Google Cloud Platform Kubernetes resources.
https://www.osinfra.io
GNU General Public License v2.0
1 stars 0 forks source link

Simplify nested ternary operator for environment variable #131

Closed coderabbitai[bot] closed 1 week ago

coderabbitai[bot] commented 3 weeks ago

The current implementation of the env variable uses a nested ternary operator, which can be complex and hard to read. To improve readability and maintainability, consider using a map-based approach.

Example Solution:

locals {
  env_map = {
    "sandbox"        = "sb"
    "non-production" = "non-prod"
    "production"     = "prod"
  }

  env = lookup(local.env_map, var.environment, "none")
}

This approach avoids nested ternary operators and makes it easier to extend in the future.