feat: use metadata package#95
Conversation
Signed-off-by: Julien Breux <julien.breux@gmail.com>
|
The original idea of this demo container was "no dependencies", and we preferred 20 lines to call metadata server that importing a package for that. That being said, we then added some packages for cloudevents, so I'm fine with this change. |
steren
left a comment
There was a problem hiding this comment.
Zone is different from Region.
As you can see in the original code, we parse the zone to extract the region.
Also, the html template expects a region and talks about region
grayside
left a comment
There was a problem hiding this comment.
Thanks for the PR, it's great to simplify to make better use of the available libraries.
| Revision: revision, | ||
| Project: project, | ||
| Region: region, | ||
| Zone: zone, |
There was a problem hiding this comment.
blocker: Cloud Run uses region not zone. While we can extract the region from the zone, we can't use it directly. We should teach using region and how to extract region from zone.
There was a problem hiding this comment.
Ok, thanks for this relevant comment!
I think region is missing from metadata package.
I need to check (sorry for delay) here: https://github.com/googleapis/google-cloud-go/blob/main/compute/metadata/metadata.go
|
Also note that Cloud Run metadata server now returns the region directly (``/computeMetadata/v1/instance/region`, but I am not totally sure this is supported on GCE. |
Description
Use of the
metadatapackage to show users how to properly obtain the metadata of an instance in Cloud Run.Note
Removal of the
regionpart in favor of thezonepart.The
regionpart is no longer part of the metadata package and API.