Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(download): Escape Go Templating #1677

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Conversation

Laubi
Copy link
Contributor

@Laubi Laubi commented Jan 23, 2025

What this PR does / Why we need it:

There are still occurances in some configs that contain {{ and }} that clash with the Go templating expressions.
This PR escapes all those occurances except for classic APIs and Automation resources.

Copy link

github-actions bot commented Jan 23, 2025

Unit Test Results

1 977 tests  +5   1 976 ✅ +5   54s ⏱️ ±0s
  134 suites  - 1       1 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 76f3148. ± Comparison against base commit 5beebaf.

This pull request removes 11 and adds 16 tests. Note that renamed tests count towards both.
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/Hello,_{{planet}}!
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/Hello_,_{{_calendar("abcde")_}}
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/\{
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/\}
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/no_jinja
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/{
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/{{
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/{{_}}
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/download/automation/internal ‑ TestEscapeJinjaTemplates/}
…
github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/download ‑ TestDownloadGoTemplateExpressionsAreEscaped
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/Hello,_{{planet}}!
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/Hello_,_{{_calendar("abcde")_}}
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/\{
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/\}
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/fetch_bizevents_|_FILTER_`event.provider`_==_$MyVariable_|_FILTER_like(event.type,\"platform.LoginEvent%\")_|_FIELDS_CountryIso,_Country_|_SUMMARIZE_quantity_=_toDouble(count()),_by:{{CountryIso,_alias:countryIso},_{Country,_alias:country}}_|_sort_quantity_desc
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/no_jinja
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/{
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/template ‑ TestEscapeGoTemplating/{{
…

♻️ This comment has been updated with latest results.

@Laubi Laubi marked this pull request as ready for review January 23, 2025 09:45
@Laubi Laubi requested a review from a team as a code owner January 23, 2025 09:45
@Laubi Laubi force-pushed the fix/download/escape-go-templating branch from 672307f to 538cc16 Compare January 23, 2025 09:45
tomazpu
tomazpu previously approved these changes Jan 23, 2025
@Laubi Laubi force-pushed the fix/download/escape-go-templating branch from 538cc16 to 2f42d76 Compare January 23, 2025 12:34
@Laubi Laubi force-pushed the fix/download/escape-go-templating branch from 2f42d76 to 76f3148 Compare January 23, 2025 12:41
@Laubi Laubi merged commit 2b3313c into main Jan 23, 2025
12 checks passed
@Laubi Laubi deleted the fix/download/escape-go-templating branch January 23, 2025 14:28
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.

3 participants