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

Simplify nested ternary operator for environment variable #8

Closed
coderabbitai bot opened this issue Sep 7, 2024 · 1 comment
Closed

Simplify nested ternary operator for environment variable #8

coderabbitai bot opened this issue Sep 7, 2024 · 1 comment

Comments

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant