Skip to content

Commit

Permalink
Simplify nested ternary operator for environment variable (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcurtis authored Sep 14, 2024
1 parent 88eb41f commit f5b7b54
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
DD_GIT_COMMIT_SHA=${{ github.sha }}
registry: us-docker.pkg.dev
service_account: plt-gke-info-github@ptl-lz-terraform-tf91-sb.iam.gserviceaccount.com
tags: us-docker.pkg.dev/plt-lz-services-tf7f-sb/platform-docker-standard/gke-info-go:${{ github.sha }}
tags: us-docker.pkg.dev/plt-lz-services-tf7f-sb/plt-docker-standard/gke-info-go:${{ github.sha }}
workload_identity_provider: projects/746490462722/locations/global/workloadIdentityPools/github-actions/providers/github-actions-oidc

us_east1_b:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:


- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.92.3
rev: v1.95.0
hooks:
- id: terraform_fmt

Expand All @@ -30,7 +30,7 @@ repos:
- --hook-config=--create-file-if-not-exist=false

- repo: https://github.com/bridgecrewio/checkov.git
rev: 3.2.238
rev: 3.2.253
hooks:
- id: checkov
files: Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {

observability.InfoWithContext(ctx, "Application is starting")

tracer.Start()
tracer.Start(tracer.WithRuntimeMetrics())
defer tracer.Stop()

err := profiler.Start(
Expand Down
8 changes: 4 additions & 4 deletions deployments/regional/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terraform Documentation

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- BEGIN_TF_DOCS -->
## Requirements

No requirements.
Expand All @@ -9,8 +9,8 @@ No requirements.

| Name | Version |
|------|---------|
| <a name="provider_datadog"></a> [datadog](#provider\_datadog) | 3.43.1 |
| <a name="provider_google"></a> [google](#provider\_google) | 6.0.1 |
| <a name="provider_datadog"></a> [datadog](#provider\_datadog) | 3.44.1 |
| <a name="provider_google"></a> [google](#provider\_google) | 6.2.0 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.32.0 |

## Modules
Expand Down Expand Up @@ -44,4 +44,4 @@ No modules.
## Outputs

No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- END_TF_DOCS -->
10 changes: 8 additions & 2 deletions deployments/regional/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ locals {
}
} : {}

env = var.environment == "sandbox" ? "sb" : var.environment == "non-production" ? "non-prod" : var.environment == "production" ? "prod" : "none"
env_map = {
"sandbox" = "sb"
"non-production" = "non-prod"
"production" = "prod"
}

registry = var.environment == "sandbox" ? "us-docker.pkg.dev/plt-lz-services-tf7f-sb/platform-docker-virtual" : "us-docker.pkg.dev/plt-lz-services-tf79-prod/platform-docker-virtual"
env = lookup(local.env_map, var.environment, "none")

registry = var.environment == "sandbox" ? "us-docker.pkg.dev/plt-lz-services-tf7f-sb/plt-docker-virtual" : "us-docker.pkg.dev/plt-lz-services-tf79-prod/plt-docker-virtual"
kubernetes_project = var.environment == "sandbox" ? "plt-k8s-tf39-sb" : var.environment == "production" ? "plt-k8s-tf10-prod" : "plt-k8s-tf33-nonprod"
}
12 changes: 6 additions & 6 deletions deployments/regional/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ provider "kubernetes" {

data "google_container_cluster" "this" {
location = var.region
name = "services-${var.region}-${var.zone}"
name = "plt-${var.region}-${var.zone}"
project = local.kubernetes_project
}

Expand Down Expand Up @@ -82,7 +82,7 @@ resource "datadog_synthetics_test" "this" {

locations = each.value.locations
message = each.value.message
name = "${each.value.name} on - region:${each.value.region} env:${var.environment}"
name = "${each.value.name} ${each.value.region} ${var.environment}"

options_list {
tick_every = 300
Expand Down Expand Up @@ -216,12 +216,12 @@ resource "kubernetes_deployment_v1" "gke_info_go" {

resources {
requests = {
cpu = "50m"
memory = "128Mi"
cpu = "100m"
memory = "64Mi"
}
limits = {
cpu = "100m"
memory = "256Mi"
cpu = "200m"
memory = "128Mi"
}
}

Expand Down
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ paths:
- cluster-name
- cluster-location
- instance-zone

responses:
'200':
description: Metadata fetched successfully
Expand Down

0 comments on commit f5b7b54

Please sign in to comment.