Merge pull request #13274 from overleaf/csh-issue-13004-cleanup-custom-code

Remove apiScheme from GCS

GitOrigin-RevId: c948287cb00c7bc432c797bfdfa92a79b84d1bed
This commit is contained in:
Christopher Hoskin
2023-06-02 08:05:10 +00:00
committed by Copybot
parent 9ddc27d919
commit 5fbd5e21a2
15 changed files with 11 additions and 41 deletions
-1
View File
@@ -295,7 +295,6 @@ GCS authentication is configured automatically via the local service account, or
- `gcs.deleteConcurrency`: when recursively deleting a directory, the maximum number of delete requests that will be used at once (default 50)
- `gcs.unsignedUrls`: For testing - do not sign GCS download URLs
- `gcs.endpoint.apiEndpoint`: For testing - specify a different GCS endpoint to use
- `gcs.endpoint.apiScheme`: For testing - specify a scheme to use for the GCS endpoint (`http` or `https`)
- `gcs.endpoint.projectId`: For testing - the GCS project ID to supply to the overridden backend
#### Notes
+2 -18
View File
@@ -16,21 +16,6 @@ module.exports = class GcsPersistor extends AbstractPersistor {
// endpoint settings will be null by default except for tests
// that's OK - GCS uses the locally-configured service account by default
this.storage = new Storage(this.settings.endpoint)
// workaround for broken uploads with custom endpoints:
// https://github.com/googleapis/nodejs-storage/issues/898
if (this.settings.endpoint && this.settings.endpoint.apiEndpoint) {
this.storage.interceptors.push({
request: reqOpts => {
const url = new URL(reqOpts.uri)
url.host = this.settings.endpoint.apiEndpoint
if (this.settings.endpoint.apiScheme) {
url.protocol = this.settings.endpoint.apiScheme
}
reqOpts.uri = url.toString()
return reqOpts
},
})
}
}
async sendFile(bucketName, key, fsPath) {
@@ -142,10 +127,9 @@ module.exports = class GcsPersistor extends AbstractPersistor {
if (this.settings.unsignedUrls) {
// Construct a direct URL to the object download endpoint
// (see https://cloud.google.com/storage/docs/request-endpoints#json-api)
const apiScheme = this.settings.endpoint.apiScheme || 'https://'
const apiEndpoint =
this.settings.endpoint.apiEndpoint || 'storage.googleapis.com'
return `${apiScheme}://${apiEndpoint}/download/storage/v1/b/${bucketName}/o/${key}?alt=media`
this.settings.endpoint.apiEndpoint || 'https://storage.googleapis.com'
return `${apiEndpoint}/download/storage/v1/b/${bucketName}/o/${key}?alt=media`
}
try {
const [url] = await this.storage
@@ -283,8 +283,7 @@ describe('GcsPersistorTests', function () {
beforeEach(async function () {
GcsPersistor.settings.unsignedUrls = true
GcsPersistor.settings.endpoint = {
apiScheme: 'http',
apiEndpoint: 'custom.endpoint',
apiEndpoint: 'http://custom.endpoint',
}
signedUrl = await GcsPersistor.getRedirectUrl(bucket, key)
})