From 568e4a5d32ef30747aee2fd0ac46d7f85026bc5b Mon Sep 17 00:00:00 2001 From: Mohammed Shaik Sahil <131136485+sahilshaik13@users.noreply.github.com> Date: Fri, 3 Oct 2025 15:24:05 +0530 Subject: [PATCH] Refactor Cloud Run functions for Go 2nd Gen Updated the Cloud Run functions to use Go 2nd Gen and modified function entry points. Enabled necessary APIs and adjusted deployment configurations. --- ...ro: Building Blocks Cloud Run functions II | 108 +++++++++++------- 1 file changed, 66 insertions(+), 42 deletions(-) diff --git a/Arcade Hero: Building Blocks Cloud Run functions II b/Arcade Hero: Building Blocks Cloud Run functions II index 38054dd..b966102 100644 --- a/Arcade Hero: Building Blocks Cloud Run functions II +++ b/Arcade Hero: Building Blocks Cloud Run functions II @@ -1,43 +1,64 @@ #!/bin/bash +# List active authentication +gcloud auth list + +# Retrieve default region from project metadata +export REGION=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-region])") + +# Retrieve project ID and project number export PROJECT_ID=$(gcloud config get-value project) -REGION1="us-central1" -FUNCTION_NAME1="cf-http-go" -REGION2="us-central1" -FUNCTION_NAME2="cf-pubsub-go" +export PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format='value(projectNumber)') + +# Enable necessary APIs +gcloud services enable cloudfunctions.googleapis.com +gcloud services enable run.googleapis.com +gcloud services enable pubsub.googleapis.com +gcloud services enable artifactregistry.googleapis.com +gcloud services enable cloudbuild.googleapis.com + +# Create directory for HTTP function +mkdir -p ~/hello-go-http && cd ~/hello-go-http -mkdir -p cloud-function-http-go -cat > cloud-function-http-go/main.go < main.go < cloud-function-http-go/go.mod < go.mod < cloud-function-pubsub-go/main.go < main.go < cloud-function-pubsub-go/go.mod < go.mod <