Add support for Google CDN
This commit adds base support for using Google CDN in front of an object storage bucket to save costs. Note that this commit does not actually enable the use of the CDN yet; additional configuration and changes to the callers must be made for this to work. To enable a bucket to use the Google CDN: 1. A CarrierWave uploader should `include ObjectStorage::CDN::Concern`. 2. Instead of calling `#url`, a caller can now call `#use_cdn?` and `#cdn_signed_url`. At the moment, transfers within the Google Cloud Platform (GCP) network between Google Cloud Storage and virutal machines are free, so serving out artifacts to GCP machines would waste money in the form of egress traffic. To avoid that, `#use_cdn?` will fetch the list of valid, public Google IP ranges and exclude IPs that are private or within the public Google network. `#cdn_signed_url` will create a pre-signed URL valid for 10 minutes by default. The Google CDN must be set up so that a Google Cloud Storage bucket is behind a unique URL. Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/360462 Changelog: added
显示
- app/uploaders/object_storage/cdn.rb 46 个添加, 0 个删除app/uploaders/object_storage/cdn.rb
- app/uploaders/object_storage/cdn/google_cdn.rb 141 个添加, 0 个删除app/uploaders/object_storage/cdn/google_cdn.rb
- config/initializers_before_autoloader/000_inflections.rb 1 个添加, 0 个删除config/initializers_before_autoloader/000_inflections.rb
- spec/fixtures/cdn/google_cloud.json 17 个添加, 0 个删除spec/fixtures/cdn/google_cloud.json
- spec/uploaders/object_storage/cdn/google_cdn_spec.rb 137 个添加, 0 个删除spec/uploaders/object_storage/cdn/google_cdn_spec.rb
- spec/uploaders/object_storage/cdn_spec.rb 85 个添加, 0 个删除spec/uploaders/object_storage/cdn_spec.rb
加载中
想要评论请 注册 或 登录