Skip to content

Commit 19750bc

Browse files
NickElliotakshat-jindal-nit
authored andcommitted
add all missing template check cases (GoogleCloudPlatform#12208)
1 parent 1d2e18b commit 19750bc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tools/template-check/gotemplate/gotemplate.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@ import (
1212
// Note: this is allowlisted to combat other issues like `=` instead of `==`, but it is possible we
1313
// need to add more options to this list in the future, like `private`. The main thing we want to
1414
// prevent is targeting `beta` in version guards, because it mishandles either `ga` or `private`.
15+
16+
// TODO: refactor to be a regex as the permitted formats are more varied under go templates
1517
var allowedGuards = []string{
1618
`{{- if ne $.TargetVersionName "ga" }}`,
17-
`{{ if ne $.TargetVersionName "ga" }}`,
1819
`{{ if ne $.TargetVersionName "ga" -}}`,
1920
`{{- if ne $.TargetVersionName "ga" -}}`,
21+
`{{ if ne $.TargetVersionName "ga" }}`,
2022
`{{- if eq $.TargetVersionName "ga" }}`,
21-
`{{ if eq $.TargetVersionName "ga" }}`,
2223
`{{ if eq $.TargetVersionName "ga" -}}`,
2324
`{{- if eq $.TargetVersionName "ga" -}}`,
25+
`{{ if eq $.TargetVersionName "ga" }}`,
2426
"{{- if ne $.TargetVersionName `ga` }}",
25-
"{{ if ne $.TargetVersionName `ga` }}",
27+
"{{ if ne $.TargetVersionName `ga` -}}",
2628
"{{- if ne $.TargetVersionName `ga` -}}",
29+
"{{ if ne $.TargetVersionName `ga` }}",
30+
"{{- if eq $.TargetVersionName `ga` }}",
31+
"{{ if eq $.TargetVersionName `ga` -}}",
32+
"{{- if eq $.TargetVersionName `ga` -}}",
33+
"{{ if eq $.TargetVersionName `ga` }}",
2734
}
2835

2936
// Note: this does not account for _every_ possible use of a version guard (for example, those

0 commit comments

Comments
 (0)