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

Firebase hosting siteconfig #6790

Closed
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
36 changes: 35 additions & 1 deletion mmv1/products/firebasehosting/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,38 @@ objects:
- !ruby/object:Api::Type::String
name: defaultUrl
output: true
description: The default URL for the site in the form of https://{name}.web.app
description: The default URL for the site in the form of https://{name}.web.app
- !ruby/object:Api::Resource
name: 'SiteConfig'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding references linking to https://firebase.devsite.corp.google.com/docs/reference/hosting/rest/v1beta1/projects.sites? Thanks!

getConfig would be preferred, but it doesn't seem to appear in c.g.c docs yet.

min_version: beta
base_url: sites/{{site_id}}
self_link: sites/{{site_id}}/config
create_url: sites/{{site_id}}/config?update_mask=maxVersions,cloudLoggingEnabled # SiteConfig is created as part of Site creation, treat as an update
create_verb: :PATCH
update_verb: :PATCH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we support update we'll need a handwritten update test (https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/third_party/terraform/README.md#update-tests). I'm seeing our current generated resource documentation doesn't say to do so. I'll fix that.

update_mask: true
description: |
A `SiteConfig` contains metadata associated with a specific site that
controls Firebase Hosting serving behavior
parameters:
- !ruby/object:Api::Type::String
name: site_id
description: |
Required. Immutable. A globally unique identifier for the Hosting site. This identifier is
used to construct the Firebase-provisioned subdomains for the site, so it must also be a valid
domain name label.
input: true
required: true
url_param_only: true
properties:
- !ruby/object:Api::Type::Integer
name: maxVersions
description: |
The number of FINALIZED versions that will be held for a site before automatic deletion. When a new
version is deployed, content for versions in storage in excess of this number will be deleted, and
will no longer be billed for storage usage. Oldest versions will be deleted first; Default is 100
default_value: 100
- !ruby/object:Api::Type::Boolean
name: cloudLoggingEnabled
description: |
Whether or not web requests made by site visitors are logged via Cloud Logging.
21 changes: 21 additions & 0 deletions mmv1/products/firebasehosting/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ overrides: !ruby/object:Overrides::ResourceOverrides
site_id: site-with-app
test_env_vars:
project_id: :PROJECT_NAME
SiteConfig: !ruby/object:Overrides::Terraform::ResourceOverride
import_format: ['sites/{{site_id}}/config', '{{site_id}}/config']
skip_delete: true # SiteConfig is a singleton child of Site
skip_sweeper: true # no sweeper
examples:
- !ruby/object:Provider::Terraform::Examples
name: "firebasehosting_siteconfig_basic"
min_version: "beta"
primary_resource_id: "default"
vars:
site_id: site-config
test_env_vars:
project_id: :PROJECT_NAME
- !ruby/object:Provider::Terraform::Examples
name: "firebasehosting_siteconfig_full"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Given how small the resource is, let's just consolidate the _full test into the basic test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since SiteConfig is a singleton child of Site, do you mean to have two Sites in one file? Which one should be the primary_resource_id then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just test all the fields in _basic and delete the _full example!

min_version: "beta"
primary_resource_id: "full"
vars:
site_id: site-config-full
test_env_vars:
project_id: :PROJECT_NAME
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_firebase_hosting_site" "default" {
provider = google-beta
project = "<%= ctx[:test_env_vars]['project_id'] %>"
site_id = "<%= ctx[:vars]['site_id'] %>"
}

resource "google_firebase_hosting_site_config" "default" {
provider = google-beta
site_id = google_firebase_hosting_site.default.site_id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_firebase_hosting_site" "default" {
provider = google-beta
project = "<%= ctx[:test_env_vars]['project_id'] %>"
site_id = "<%= ctx[:vars]['site_id'] %>"
}

resource "google_firebase_hosting_site_config" "full" {
provider = google-beta
site_id = google_firebase_hosting_site.default.site_id
max_versions = 100
cloud_logging_enabled = true
}