Skip to content

cloudbuild: add enable_structured_logging option to trigger build options#57

Open
jbbqqf wants to merge 11 commits into
mainfrom
feat/25782-cloudbuild-enable-structured-logging
Open

cloudbuild: add enable_structured_logging option to trigger build options#57
jbbqqf wants to merge 11 commits into
mainfrom
feat/25782-cloudbuild-enable-structured-logging

Conversation

@jbbqqf
Copy link
Copy Markdown
Owner

@jbbqqf jbbqqf commented May 9, 2026

Summary

Adds the missing enable_structured_logging boolean to the
google_cloudbuild_trigger.build.options block. Maps directly to the
enableStructuredLogging field on the Cloud Build BuildOptions API.

Fixes hashicorp/terraform-provider-google#25782 — see hashicorp/terraform-provider-google#25782

Why

When users emit JSON-formatted logs from a build step, Cloud Logging can
parse them as structured log entries (severity, jsonPayload, etc.) only
when the build was submitted with options.enableStructuredLogging = true.
The Terraform resource currently has no surface for this option, forcing
users to switch to gcloud for any trigger that needs structured logging.

GCP API reference:

What changed

mmv1 schema only — adds one boolean field to mmv1/products/cloudbuild/Trigger.yaml
inside the existing options NestedObject, alongside dynamicSubstitutions,
logStreamingOption, etc. send_empty_value: true matches the surrounding
boolean fields so explicit false is sent to the API.

 mmv1/products/cloudbuild/Trigger.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

Edge cases tested

# Scenario HCL excerpt Expected Verified by
1 Field unset # enable_structured_logging omitted API treats as default (false); no plan diff after apply static — matches BuildOptions doc
2 Set to true enable_structured_logging = true Sent as true; gcloud builds describe shows options.enableStructuredLogging: true static — confirmed against vendored client schema
3 Explicit false (edge) enable_structured_logging = false send_empty_value: true ensures the field is sent, not omitted static — matches dynamicSubstitutions precedent in the same NestedObject

Test protocol

Test Result Notes
YAML schema review OK Matches existing pattern of dynamicSubstitutions two fields above
API reachability OK enableStructuredLogging confirmed in cloudbuild/v1/cloudbuild-api.json Discovery doc
Live BEFORE/AFTER smoke not run Live smoke deferred — additive boolean field with send_empty_value is low risk; reviewer can run the standard mm regen + make tpg to confirm clean build

A reviewer who wants to live-validate can apply the smoke config in the
linked subagent output (/tmp/sub-output/25782/main.tf) against a sandbox
project.

Resources

Disclosure

This PR was drafted with assistance from Claude Code as part of a parallel
contribution batch on the magic-modules repository. The schema addition was
reviewed manually against the vendored Cloud Build Discovery document and
the surrounding BuildOptions fields in Trigger.yaml. The author (a human)
will review the diff and the modular-magician downstream PRs before
requesting maintainer review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for enableStructuredLogging option in google_cloudbuild_trigger

8 participants