Skip to content

feat(config): add Go template AST validator for bicepparam files#255

Open
geoberle wants to merge 1 commit into
mainfrom
gotmp-ast-guards
Open

feat(config): add Go template AST validator for bicepparam files#255
geoberle wants to merge 1 commit into
mainfrom
gotmp-ast-guards

Conversation

@geoberle

Copy link
Copy Markdown
Collaborator

In EV2, Go template field lookups in bicepparam files are translated into scope bindings, but complex constructs (range, if, variables, functions) are silently ignored. templatize processes the full Go template locally, giving developers false confidence that these constructs work — they don't once deployed via EV2.

Add ValidateSimpleFieldAccess() that parses templates and walks the AST, allowing only simple field access ({{ .field.name }}). Returns all violations with line numbers.

https://redhat.atlassian.net/browse/ARO-27904

/hold until all current issues in ARO-HCP and sdp-pipelines have been resolved

Copilot AI review requested due to automatic review settings June 22, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Go text/template AST-based validator to ensure .bicepparam template content only uses simple field access (e.g. {{ .field.name }}), preventing developers from relying on template constructs that EV2 will not honor.

Changes:

  • Introduces ValidateSimpleFieldAccess([]byte) error to parse templates and walk the AST, collecting restricted-construct violations with line numbers.
  • Adds unit tests covering allowed field access patterns, common disallowed constructs (if/range/with, variables, function calls, pipes, template invocation), and line-number reporting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
config/validate.go Implements Go template parsing + AST walk to detect and report restricted constructs.
config/validate_test.go Adds test coverage for allowed/disallowed constructs and expected error messages/line numbers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config/validate.go
In EV2, Go template field lookups in bicepparam files are translated
into scope bindings, but complex constructs (range, if, variables,
functions) are silently ignored. templatize processes the full Go
template locally, giving developers false confidence that these
constructs work — they don't once deployed via EV2.

Add ValidateSimpleFieldAccess() that parses templates and walks the AST,
allowing only simple field access ({{ .field.name }}). Returns all
violations with line numbers.

https://redhat.atlassian.net/browse/ARO-27904

@raelga raelga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@stevekuznetsov stevekuznetsov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it.

/lgtm
/approve

@stevekuznetsov stevekuznetsov enabled auto-merge (rebase) June 23, 2026 12:42
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.

4 participants