Skip to content

[FEAT] Add GCP Cloud Function support to Go template #59

@colbytimm

Description

@colbytimm

Summary

The Go template currently only supports Azure Function App. Add GCP Cloud Function as a cloud_service option using the Go Functions Framework (github.com/GoogleCloudPlatform/functions-framework-go). Includes a Firestore repository using cloud.google.com/go/firestore.

Category: gcp, go

Acceptance Criteria

  • cookiecutter.json includes "GCP Cloud Function" in cloud_service choices
  • GCP entry point using github.com/GoogleCloudPlatform/functions-framework-go
  • Firestore repository using cloud.google.com/go/firestore SDK implementing all CRUD operations
  • go.mod conditionally includes GCP dependencies via Jinja2
  • hooks/ directory with pre/post gen scripts for input validation and file cleanup
  • Environment variables: GCP_PROJECT_ID, FIRESTORE_DATABASE, FIRESTORE_COLLECTION
  • Unit tests pass for GCP variant with mocked Firestore client
  • CI pipeline matrix includes GCP Cloud Function
  • README updated with GCP-specific setup instructions

Implementation Notes

Go GCP Dependencies

  • github.com/GoogleCloudPlatform/functions-framework-go (function hosting)
  • cloud.google.com/go/firestore (Firestore client)
  • google.golang.org/api (Google API core)

Key Files to Modify/Create

  • go/cookiecutter.json — Add "GCP Cloud Function" to choices
  • go/{{cookiecutter.project_class_name}}/repositories/repository.go — Add Jinja2 conditional for Firestore client
  • go/{{cookiecutter.project_class_name}}/main.go — Add GCP entry point (Jinja2 conditional, separate from Azure custom handler)
  • go/{{cookiecutter.project_class_name}}/go.mod — Conditional GCP dependencies
  • go/hooks/pre_gen_project.py — Input validation (new)
  • go/hooks/post_gen_project.py — Cloud-specific file cleanup (new)
  • .github/workflows/build-go-pipeline.yaml — Add GCP Cloud Function to matrix
  • Makefile — Add GCP-specific run command using functions-framework

GCP Cloud Function Entry Point Pattern (Go)

package function

import (
    "github.com/GoogleCloudPlatform/functions-framework-go/functions"
    "net/http"
)

func init() {
    functions.HTTP("GetList", getList)
    functions.HTTP("Get", get)
    // ... etc
}

Reference

Python and TypeScript templates already support GCP — follow their Jinja2 conditional patterns for consistency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions