Skip to content

Commit

Permalink
cleanup: use metadata.ProjectID instead of passing via env (#26)
Browse files Browse the repository at this point in the history
Cloud Run services know what project they're running in, let's just use
that.

Signed-off-by: Jason Hall <[email protected]>
  • Loading branch information
imjasonh authored Dec 22, 2023
1 parent 02b9dec commit 053eec0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 3 additions & 4 deletions cloudevent-broker/cmd/ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ const (
)

type envConfig struct {
Port int `envconfig:"PORT" default:"8080" required:"true"`
Project string `envconfig:"PROJECT_ID" required:"true"`
Topic string `envconfig:"PUBSUB_TOPIC" required:"true"`
Port int `envconfig:"PORT" default:"8080" required:"true"`
Topic string `envconfig:"PUBSUB_TOPIC" required:"true"`
}

func main() {
Expand All @@ -44,7 +43,7 @@ func main() {
log.Fatalf("failed to create CE client, %v", err)
}

psc, err := pubsub.NewClient(ctx, env.Project, option.WithTokenSource(google.ComputeTokenSource("")))
psc, err := pubsub.NewClient(ctx, pubsub.DetectProjectID, option.WithTokenSource(google.ComputeTokenSource("")))
if err != nil {
log.Fatalf("failed to create pubsub client, %v", err)
}
Expand Down
6 changes: 1 addition & 5 deletions cloudevent-broker/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ resource "google_cloud_run_v2_service" "this" {
containers {
image = cosign_sign.this.signed_ref

env {
name = "PROJECT_ID"
value = var.project_id
}
env {
name = "PUBSUB_TOPIC"
value = google_pubsub_topic.this[each.key].name
Expand Down Expand Up @@ -108,7 +104,7 @@ module "resources" {
module "width" { source = "../dashboard/sections/width" }

module "layout" {
source = "../dashboard/sections/layout"
source = "../dashboard/sections/layout"
sections = [
module.topic.section,
module.logs.section,
Expand Down

0 comments on commit 053eec0

Please sign in to comment.