TechDocs/GCS: Remove projectId since it is not needed
I initially thought the GCS Nodejs client would make use of it, since it asked for it in the contructor. However, we may not need them at all. Buckets are gloablly unique anyway.
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
type storageOptions = {
|
||||
projectId?: string;
|
||||
keyFilename?: string;
|
||||
};
|
||||
|
||||
@@ -39,11 +38,9 @@ class Bucket {
|
||||
}
|
||||
|
||||
export class Storage {
|
||||
private readonly projectId;
|
||||
private readonly keyFilename;
|
||||
|
||||
constructor(options: storageOptions) {
|
||||
this.projectId = options.projectId;
|
||||
this.keyFilename = options.keyFilename;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ jest.spyOn(logger, 'info').mockReturnValue(logger);
|
||||
|
||||
let publisher: PublisherBase;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
const mockConfig = new ConfigReader({
|
||||
techdocs: {
|
||||
requestUrl: 'http://localhost:7000',
|
||||
@@ -45,14 +45,13 @@ beforeEach(() => {
|
||||
type: 'googleGcs',
|
||||
googleGcs: {
|
||||
credentials: '{}',
|
||||
projectId: 'gcp-project-id',
|
||||
bucketName: 'bucketName',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
publisher = GoogleGCSPublish.fromConfig(mockConfig, logger);
|
||||
publisher = await GoogleGCSPublish.fromConfig(mockConfig, logger);
|
||||
});
|
||||
|
||||
describe('GoogleGCSPublish', () => {
|
||||
|
||||
@@ -56,15 +56,11 @@ export class GoogleGCSPublish implements PublisherBase {
|
||||
);
|
||||
}
|
||||
}
|
||||
const projectId = config.getOptionalString(
|
||||
'techdocs.publisher.googleGcs.projectId',
|
||||
);
|
||||
|
||||
const storageClient = new Storage({
|
||||
...(credentials && {
|
||||
credentials: credentialsJson,
|
||||
}),
|
||||
...(projectId && { projectId }),
|
||||
});
|
||||
|
||||
// Check if the defined bucket exists. Being able to connect means the configuration is good
|
||||
|
||||
@@ -69,7 +69,6 @@ describe('Publisher', () => {
|
||||
type: 'googleGcs',
|
||||
googleGcs: {
|
||||
credentials: '{}',
|
||||
projectId: 'gcp-project-id',
|
||||
bucketName: 'bucketName',
|
||||
},
|
||||
},
|
||||
|
||||
Vendored
+6
-12
@@ -122,6 +122,12 @@ export interface Config {
|
||||
* googleGcs required when 'type' is set to googleGcs
|
||||
*/
|
||||
googleGcs?: {
|
||||
/**
|
||||
* Cloud Storage Bucket Name
|
||||
* attr: 'bucketName' - accepts a string value
|
||||
* @visibility secret
|
||||
*/
|
||||
bucketName: string;
|
||||
/**
|
||||
* (Optional) API key used to write to a storage bucket.
|
||||
* If not set, environment variables will be used to authenticate.
|
||||
@@ -130,18 +136,6 @@ export interface Config {
|
||||
* @visibility secret
|
||||
*/
|
||||
credentials?: string;
|
||||
/**
|
||||
* GCP Project ID where the Cloud Storage Bucket is hosted.
|
||||
* attr: 'projectId' - accepts a string value
|
||||
* @visibility secret
|
||||
*/
|
||||
projectId?: string;
|
||||
/**
|
||||
* Cloud Storage Bucket Name
|
||||
* attr: 'bucketName' - accepts a string value
|
||||
* @visibility secret
|
||||
*/
|
||||
bucketName: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user