diff --git a/.changeset/dull-bottles-learn.md b/.changeset/dull-bottles-learn.md new file mode 100644 index 0000000000..e279f9e0ad --- /dev/null +++ b/.changeset/dull-bottles-learn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-gcp-projects': patch +--- + +Add a `x-google-api-client` header for calls towards Google Cloud Projects diff --git a/plugins/gcp-projects/src/api/GcpClient.ts b/plugins/gcp-projects/src/api/GcpClient.ts index 10dcb5a4c8..e9375bcfa6 100644 --- a/plugins/gcp-projects/src/api/GcpClient.ts +++ b/plugins/gcp-projects/src/api/GcpClient.ts @@ -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), }); diff --git a/plugins/gcp-projects/src/plugin.test.ts b/plugins/gcp-projects/src/plugin.test.ts index 7b644d1400..8b53d0f0f0 100644 --- a/plugins/gcp-projects/src/plugin.test.ts +++ b/plugins/gcp-projects/src/plugin.test.ts @@ -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(); + }); });