Add header for calls towards Google Cloud Projects

Signed-off-by: armandocomellas1 <cgarmando@google.com>
This commit is contained in:
armandocomellas1
2024-02-15 15:00:38 -06:00
parent 652ccd65df
commit 984d5084d1
3 changed files with 13 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-gcp-projects': patch
---
Add a `x-google-api-client` header for calls towards Google Cloud Projects
@@ -17,6 +17,7 @@
import { GcpApi } from './GcpApi';
import { Operation, Project } from './types';
import { OAuthApi } from '@backstage/core-plugin-api';
import packageinfo from '../../package.json';
const BASE_URL =
'https://content-cloudresourcemanager.googleapis.com/v1/projects';
@@ -30,6 +31,7 @@ export class GcpClient implements GcpApi {
headers: {
Accept: '*/*',
Authorization: `Bearer ${await this.getToken()}`,
'X-Goog-Api-Client': `backstage/cloudbuild/${packageinfo.version}`,
},
});
@@ -48,6 +50,7 @@ export class GcpClient implements GcpApi {
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${await this.getToken()}`,
'X-Goog-Api-Client': `backstage/cloudbuild/${packageinfo.version}`,
},
});
@@ -74,6 +77,7 @@ export class GcpClient implements GcpApi {
headers: {
Accept: '*/*',
Authorization: `Bearer ${await this.getToken()}`,
'X-Goog-Api-Client': `backstage/cloudbuild/${packageinfo.version}`,
},
body: JSON.stringify(newProject),
});
+4
View File
@@ -15,9 +15,13 @@
*/
import { gcpProjectsPlugin } from './plugin';
import * as container from '@backstage/plugin-gcp-projects';
describe('gcp-projects', () => {
it('should export plugin', () => {
expect(gcpProjectsPlugin).toBeDefined();
});
it('should exist the GcpClient class', () => {
expect(container.GcpClient).toBeDefined();
});
});