chore: use BACKSTAGE_VERSIONS_BASE_URL instead
Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
@@ -29,7 +29,7 @@ backstage.json.
|
||||
|
||||
The plugin functionality can be configured with environment variables:
|
||||
|
||||
- `BACKSTAGE_MANIFEST_BASE_URL` - The base URL for fetching the Backstage version
|
||||
- `BACKSTAGE_VERSIONS_BASE_URL` - The base URL for fetching the Backstage version
|
||||
manifest. Defaults to `https://versions.backstage.io/v1/releases/VERSION/manifest.json`.
|
||||
Useful for running the plugin in environment without direct access to the internet,
|
||||
for example by using a mirror of the versions API or a proxy.
|
||||
|
||||
@@ -43,8 +43,6 @@ describe('getPackageVersion', () => {
|
||||
const mockConfiguration = {} as Configuration;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
mockGetCurrentBackstageVersion.mockReturnValue('1.23.4');
|
||||
mockStructUtils.stringifyIdent.mockImplementation(
|
||||
(descriptor: any) =>
|
||||
@@ -59,6 +57,10 @@ describe('getPackageVersion', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('successful package resolution', () => {
|
||||
beforeEach(() => {
|
||||
mockHttpUtils.get.mockResolvedValue({
|
||||
@@ -96,8 +98,8 @@ describe('getPackageVersion', () => {
|
||||
});
|
||||
|
||||
it('uses custom versionsBaseUrl from environment when provided', async () => {
|
||||
const originalEnv = process.env.BACKSTAGE_MANIFEST_BASE_URL;
|
||||
process.env.BACKSTAGE_MANIFEST_BASE_URL = 'https://custom.example.com';
|
||||
const originalEnv = process.env.BACKSTAGE_VERSIONS_BASE_URL;
|
||||
process.env.BACKSTAGE_VERSIONS_BASE_URL = 'https://custom.example.com';
|
||||
|
||||
const descriptor = {
|
||||
scope: '@backstage',
|
||||
@@ -113,7 +115,7 @@ describe('getPackageVersion', () => {
|
||||
fetch: expect.any(Function),
|
||||
});
|
||||
|
||||
process.env.BACKSTAGE_MANIFEST_BASE_URL = originalEnv;
|
||||
process.env.BACKSTAGE_VERSIONS_BASE_URL = originalEnv;
|
||||
});
|
||||
|
||||
it('uses yarn httpUtils for fetching with proper response format', async () => {
|
||||
|
||||
@@ -52,7 +52,7 @@ export const getPackageVersion = async (
|
||||
? await xfs.readJsonSync(manifestFile as PortablePath)
|
||||
: await getManifestByVersion({
|
||||
version: backstageVersion,
|
||||
versionsBaseUrl: env.BACKSTAGE_MANIFEST_BASE_URL,
|
||||
versionsBaseUrl: env.BACKSTAGE_VERSIONS_BASE_URL,
|
||||
// We override the fetch function used inside getManifestByVersion with a
|
||||
// custom implementation that calls yarn's built-in `httpUtils` method
|
||||
// instead. This has a couple of benefits:
|
||||
|
||||
Reference in New Issue
Block a user