Skip to content

Commit 5fd6dd4

Browse files
committed
Add test for complex envvars with special characters
This requires changing the test inputs to expect JSON instead of K=V pairs in our e2e runner.
1 parent 4d52883 commit 5fd6dd4

File tree

9 files changed

+352
-264
lines changed

9 files changed

+352
-264
lines changed

.github/workflows/integration.yml

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
service: '${{ env.SERVICE_NAME }}'
6363
env_vars: |-
6464
FOO=bar
65-
ZIP=zap
65+
ZIP=zap\,with|separators\,and&stuff
6666
env_vars_file: './tests/fixtures/env_vars.txt'
6767
secrets: |-
6868
MY_SECRET=${{ vars.SECRET_NAME }}:latest
@@ -77,10 +77,28 @@ jobs:
7777
env:
7878
PROJECT_ID: ${{ vars.PROJECT_ID }}
7979
SERVICE: '${{ env.SERVICE_NAME }}'
80-
ENV: 'FOO=bar,ZIP=zap,TEXT_FOO=bar,TEXT_ZIP=zap'
81-
SECRET_ENV: MY_SECRET=${{ vars.SECRET_NAME }}:latest,MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
82-
PARAMS: '{"cpu":2, "containerConcurrency":20}'
83-
LABELS: '{"label1":"value1", "label2":"value2"}'
80+
ENV: |-
81+
{
82+
"FOO": "bar",
83+
"ZIP": "zap,with|separators,and&stuff",
84+
"TEXT_FOO": "bar",
85+
"TEXT_ZIP": "zap"
86+
}
87+
SECRET_ENV: |-
88+
{
89+
"MY_SECRET": "${{ vars.SECRET_NAME }}:latest",
90+
"MY_SECOND_SECRET": "${{ vars.SECRET_NAME }}:1"
91+
}
92+
PARAMS: |-
93+
{
94+
"cpu": "2",
95+
"containerConcurrency": "20"
96+
}
97+
LABELS: |-
98+
{
99+
"label1": "value1",
100+
"label2": "value2"
101+
}
84102
85103
- id: 'deploy-cloudrun-again'
86104
name: 'Deploy again'
@@ -98,11 +116,36 @@ jobs:
98116
env:
99117
PROJECT_ID: ${{ vars.PROJECT_ID }}
100118
SERVICE: '${{ env.SERVICE_NAME }}'
101-
ENV: 'FOO=bar,ZIP=zap,TEXT_FOO=bar,TEXT_ZIP=zap,ABC=123,DEF=456'
102-
SECRET_ENV: MY_SECRET=${{ vars.SECRET_NAME }}:latest,MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
103-
SECRET_VOLUMES: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
104-
PARAMS: '{"cpu":2, "containerConcurrency":20}'
105-
LABELS: '{"label1":"value1", "label2":"value2", "commit-sha":"${{ github.sha }}", "managed-by":"github-actions"}'
119+
ENV: |-
120+
{
121+
"FOO": "bar",
122+
"ZIP": "zap,with|separators,and&stuff",
123+
"TEXT_FOO": "bar",
124+
"TEXT_ZIP": "zap,with|separators,and&stuff",
125+
"ABC": "123",
126+
"DEF": "456"
127+
}
128+
SECRET_ENV: |-
129+
{
130+
"MY_SECRET": "${{ vars.SECRET_NAME }}:latest",
131+
"MY_SECOND_SECRET": "${{ vars.SECRET_NAME }}:1"
132+
}
133+
SECRET_VOLUMES: |-
134+
{
135+
"/api/secrets/my-secret": "${{ vars.SECRET_NAME }}:latest"
136+
}
137+
PARAMS: |-
138+
{
139+
"cpu": "2",
140+
"containerConcurrency": "20"
141+
}
142+
LABELS: |-
143+
{
144+
"label1": "value1",
145+
"label2": "value2",
146+
"commit-sha": "${{ github.sha }}",
147+
"managed-by": "github-actions"
148+
}
106149
REVISION_COUNT: 2
107150

108151
metadata:
@@ -141,9 +184,20 @@ jobs:
141184
env:
142185
PROJECT_ID: '${{ vars.PROJECT_ID }}'
143186
SERVICE: '${{ env.SERVICE_NAME }}'
144-
PARAMS: '{"cpu":2, "memory":"1Gi", "containerConcurrency":20}'
145-
ANNOTATIONS: '{"run.googleapis.com/cloudsql-instances":"test-project:us-central1:my-test-instance"}'
146-
LABELS: '{"test_label":"test_value"}'
187+
PARAMS: |-
188+
{
189+
"cpu": "2",
190+
"memory": "1Gi",
191+
"containerConcurrency": "20"
192+
}
193+
ANNOTATIONS: |-
194+
{
195+
"run.googleapis.com/cloudsql-instances": "test-project:us-central1:my-test-instance"
196+
}
197+
LABELS: |-
198+
{
199+
"test_label": "test_value"
200+
}
147201
148202
- id: 'deploy-cloudrun-again'
149203
name: 'Deploy again'
@@ -156,6 +210,14 @@ jobs:
156210
env:
157211
PROJECT_ID: '${{ vars.PROJECT_ID }}'
158212
SERVICE: '${{ env.SERVICE_NAME }}'
159-
PARAMS: '{"cpu":2, "memory":"1Gi", "containerConcurrency":20}'
160-
ANNOTATIONS: '{"run.googleapis.com/cloudsql-instances":"test-project:us-central1:my-test-instance"}'
213+
PARAMS: |-
214+
{
215+
"cpu": "2",
216+
"memory": "1Gi",
217+
"containerConcurrency": "20"
218+
}
219+
ANNOTATIONS: |-
220+
{
221+
"run.googleapis.com/cloudsql-instances": "test-project:us-central1:my-test-instance"
222+
}
161223
REVISION_COUNT: 2

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ jobs:
9797
ZIP=zap
9898
```
9999

100+
Entries are separated by commas (`,`) and newline characters. Keys and
101+
values are separated by `=`. To use `,`, `=`, or newline characters, escape
102+
them with a backslash:
103+
104+
```yaml
105+
with:
106+
env_vars: |
107+
108+
```
109+
100110
- `env_vars_file`: (Optional) Path to a file on disk, relative to the
101111
workspace, that defines environment variables. The file can be
102112
newline-separated KEY=VALUE pairs, JSON, or YAML format. If both `env_vars`
@@ -124,6 +134,9 @@ jobs:
124134
ZIP: 'zap'
125135
```
126136

137+
When specified as KEY=VALUE pairs, the same escaping rules apply as
138+
described in `env_vars`. You do not have to escape YAML or JSON.
139+
127140
- `secrets`: (Optional) List of key=value pairs to use as secrets. These can
128141
either be injected as environment variables or mounted as volumes. All
129142
existing environment secrets and volume mounts will be retained.
@@ -138,6 +151,9 @@ jobs:
138151
/secrets/api/key=secret-key-2:latest
139152
```
140153

154+
The same rules apply for escaping entries as from `env_vars`, but Cloud Run
155+
is more restrictive with allowed keys and names for secrets.
156+
141157
- `labels`: (Optional) List of key=value pairs to set as labels on the Cloud
142158
Run service. Existing labels will be overwritten.
143159

@@ -147,7 +163,8 @@ jobs:
147163
my-label=my-value
148164
```
149165

150-
Labels have strict naming and casing requirements. See [Requirements for
166+
The same rules apply for escaping entries as from `env_vars`, but labels
167+
have strict naming and casing requirements. See [Requirements for
151168
labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
152169
for more information.
153170

dist/main/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)