Skip to content

Commit

Permalink
Escape {{ and }} in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
lfritz committed Feb 28, 2024
1 parent 9e917b3 commit 790a11d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
8 changes: 1 addition & 7 deletions gootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,8 @@ func generate(name, group string, templateFS fs.FS, templateDir string) {
}

applyTemplate := func(templ string) string {
// Why: some files, like Github CI files, have notation identical
// To Go templates. So for now we just try to apply the template and if it
// fails we assume it should be used as is (not the safest option, but no more time to deal
// with this right now).
t, err := template.New("templ").Parse(templ)
if err != nil {
return templ
}
assert(err)
result := bytes.Buffer{}
assert(t.Execute(&result, info))
return result.String()
Expand Down
6 changes: 3 additions & 3 deletions templates/basic/.github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
uses: "google-github-actions/auth@v2"
with:
token_format: access_token
workload_identity_provider: ${{ vars.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GOOGLE_SERVICE_ACCOUNT }}
workload_identity_provider: ${{"{{"}} vars.GOOGLE_WORKLOAD_IDENTITY_PROVIDER {{"}}"}}
service_account: ${{"{{"}} vars.GOOGLE_SERVICE_ACCOUNT {{"}}"}}
access_token_lifetime: 300s

- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev/birdie-org/birdie
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
password: ${{"{{"}} steps.auth.outputs.access_token {{"}}"}}

- name: Publish image
run: |
Expand Down
6 changes: 3 additions & 3 deletions templates/basic/.github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ jobs:
uses: "google-github-actions/auth@v2"
with:
token_format: access_token
workload_identity_provider: ${{ vars.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GOOGLE_SERVICE_ACCOUNT }}
workload_identity_provider: ${{"{{"}} vars.GOOGLE_WORKLOAD_IDENTITY_PROVIDER {{"}}"}}
service_account: ${{"{{"}} vars.GOOGLE_SERVICE_ACCOUNT {{"}}"}}
access_token_lifetime: 300s

- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev/birdie-org/birdie
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
password: ${{"{{"}} steps.auth.outputs.access_token {{"}}"}}

- name: Release
run: make release

0 comments on commit 790a11d

Please sign in to comment.