cloudbuild: add enable_structured_logging option to trigger build options#57
Open
jbbqqf wants to merge 11 commits into
Open
cloudbuild: add enable_structured_logging option to trigger build options#57jbbqqf wants to merge 11 commits into
jbbqqf wants to merge 11 commits into
Conversation
…25782) Adds the `enable_structured_logging` boolean to the `google_cloudbuild_trigger.build.options` block, mapping to the API field `enableStructuredLogging` documented on the BuildOptions schema. When true, JSON-formatted logs from build steps are parsed as structured logs by Cloud Logging. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the missing
enable_structured_loggingboolean to thegoogle_cloudbuild_trigger.build.optionsblock. Maps directly to theenableStructuredLoggingfield on the Cloud BuildBuildOptionsAPI.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:
enableStructuredLogging)cloudbuild/v1/cloudbuild-gen.go(BuildOptions.EnableStructuredLogging bool)What changed
mmv1 schema only — adds one boolean field to
mmv1/products/cloudbuild/Trigger.yamlinside the existing
optionsNestedObject, alongsidedynamicSubstitutions,logStreamingOption, etc.send_empty_value: truematches the surroundingboolean fields so explicit
falseis sent to the API.Edge cases tested
# enable_structured_logging omittedtrueenable_structured_logging = truetrue; gcloudbuilds describeshowsoptions.enableStructuredLogging: truefalse(edge)enable_structured_logging = falsesend_empty_value: trueensures the field is sent, not omitteddynamicSubstitutionsprecedent in the same NestedObjectTest protocol
dynamicSubstitutionstwo fields aboveenableStructuredLoggingconfirmed incloudbuild/v1/cloudbuild-api.jsonDiscovery docsend_empty_valueis low risk; reviewer can run the standard mm regen +make tpgto confirm clean buildA reviewer who wants to live-validate can apply the smoke config in the
linked subagent output (
/tmp/sub-output/25782/main.tf) against a sandboxproject.
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
BuildOptionsfields inTrigger.yaml. The author (a human)will review the diff and the modular-magician downstream PRs before
requesting maintainer review.