Add header for calls towards Google Cloud Projects
Signed-off-by: armandocomellas1 <cgarmando@google.com>
This commit is contained in:
@@ -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),
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user