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

Add headers to Hosting Version #12527

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 70 additions & 25 deletions mmv1/products/firebasehosting/Version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ base_url: 'sites/{{site_id}}/versions'
self_link: 'sites/{{site_id}}/versions/{{version_id}}'
create_url: 'sites/{{site_id}}/versions'
exclude_delete: true
# not updatable
# not updatable
immutable: true
import_format:
- 'sites/{{site_id}}/versions/{{version_id}}'
Expand All @@ -46,6 +46,20 @@ examples:
site_id: 'site-id'
test_env_vars:
project_id: 'PROJECT_NAME'
- name: 'firebasehosting_version_headers'
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
primary_resource_id: 'default'
min_version: 'beta'
vars:
site_id: 'site-id'
test_env_vars:
project_id: 'PROJECT_NAME'
- name: 'firebasehosting_version_headers_regex'
primary_resource_id: 'default'
min_version: 'beta'
vars:
site_id: 'site-id'
test_env_vars:
project_id: 'PROJECT_NAME'
- name: 'firebasehosting_version_path'
primary_resource_id: 'default'
min_version: 'beta'
Expand Down Expand Up @@ -126,45 +140,45 @@ properties:
description:
The user-supplied glob to match against the request URL path.
min_version: 'beta'
exactly_one_of:
- 'glob'
- 'regex'
# exactly_one_of:
# - 'glob'
# - 'regex'
- name: 'regex'
type: String
description:
The user-supplied RE2 regular expression to match against the
request URL path.
min_version: 'beta'
exactly_one_of:
- 'glob'
- 'regex'
# exactly_one_of:
# - 'glob'
# - 'regex'
- name: 'path'
type: String
description:
The URL path to rewrite the request to.
min_version: 'beta'
exactly_one_of:
- 'path'
- 'function'
- 'run'
# exactly_one_of:
# - 'path'
# - 'function'
# - 'run'
- name: 'function'
type: String
description:
The function to proxy requests to. Must match the exported
function name exactly.
min_version: 'beta'
exactly_one_of:
- 'path'
- 'function'
- 'run'
# exactly_one_of:
# - 'path'
# - 'function'
# - 'run'
- name: 'run'
type: NestedObject
description: The request will be forwarded to Cloud Run.
min_version: 'beta'
exactly_one_of:
- 'path'
- 'function'
- 'run'
# exactly_one_of:
# - 'path'
# - 'function'
# - 'run'
properties:
- name: 'serviceId'
type: String
Expand Down Expand Up @@ -194,18 +208,18 @@ properties:
description:
The user-supplied glob to match against the request URL path.
min_version: 'beta'
exactly_one_of:
- 'glob'
- 'regex'
# exactly_one_of:
# - 'glob'
# - 'regex'
- name: 'regex'
type: String
description:
The user-supplied RE2 regular expression to match against the
request URL path.
min_version: 'beta'
exactly_one_of:
- 'glob'
- 'regex'
# exactly_one_of:
# - 'glob'
# - 'regex'
- name: 'statusCode'
type: Integer
description:
Expand All @@ -229,3 +243,34 @@ properties:
```
min_version: 'beta'
required: true
- name: 'headers'
type: Array
description: |
An array of objects, where each object specifies a URL pattern that, if matched to the request URL path,
triggers Hosting to apply the specified custom response headers.
item_type:
description: |
A Header specifies a URL pattern that, if matched to the request URL path, triggers Hosting
to apply the specified custom response headers.
type: NestedObject
properties:
- name: 'glob'
type: String
description:
The user-supplied glob to match against the request URL path.
# exactly_one_of:
# - 'glob'
# - 'regex'
- name: 'regex'
type: String
description:
The user-supplied RE2 regular expression to match against the
request URL path.
# exactly_one_of:
# - 'glob'
# - 'regex'
- name: 'headers'
type: KeyValuePairs
description: |
The additional headers to add to the response. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
required: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "google_firebase_hosting_site" "default" {
provider = google-beta
project = "{{index $.TestEnvVars "project_id"}}"
site_id = "{{index $.Vars "site_id"}}"
}

resource "google_firebase_hosting_version" "default" {
provider = google-beta
site_id = google_firebase_hosting_site.default.site_id
config {
headers {
# Also okay to use regex
glob = "/headers/**"
headers = {
my-header = "my-value"
}
}
}
}

resource "google_firebase_hosting_release" "default" {
provider = google-beta
site_id = google_firebase_hosting_site.default.site_id
version_name = google_firebase_hosting_version.default.name
message = "With custom headers"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "google_firebase_hosting_site" "default" {
provider = google-beta
project = "{{index $.TestEnvVars "project_id"}}"
site_id = "{{index $.Vars "site_id"}}"
}

resource "google_firebase_hosting_version" "default" {
provider = google-beta
site_id = google_firebase_hosting_site.default.site_id
config {
headers {
# Also okay to use glob
regex = "^~/headers$"
headers = {
my-header = "my-value"
}
}
}
}

resource "google_firebase_hosting_release" "default" {
provider = google-beta
site_id = google_firebase_hosting_site.default.site_id
version_name = google_firebase_hosting_version.default.name
message = "With custom headers"
}
Loading