diff --git a/app-config.example.yaml b/app-config.example.yaml index 3dd8ff1..6c6a678 100644 --- a/app-config.example.yaml +++ b/app-config.example.yaml @@ -8,14 +8,8 @@ catalog: locations: - type: file target: ../../default-catalog/catalog-info.yaml - - type: file - target: ../../examples/entities.yaml - - type: file - target: ../../examples/org.yaml - type: file target: ../../examples/all.yaml - - type: file - target: ../../examples/acme-corp.yaml ## Uncomment the following to enable Plausible analytics in development mode # plausible: # enabled: true diff --git a/app-config.production.yaml b/app-config.production.yaml index cd3560c..b6c06d0 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -47,9 +47,7 @@ auth: # See https://backstage.io/docs/auth/github/provider#resolvers for more resolvers. - resolver: usernameMatchingUserEntityName catalog: - # Overrides the default list locations from app-config.yaml as these contain example data. - # See https://backstage.io/docs/features/software-catalog/#adding-components-to-the-catalog for more details - # on how to get entities into the catalog. + # Load sample entities, including guest users, groups and templates, from one location. providers: github: default: @@ -61,14 +59,8 @@ catalog: timeout: { minutes: 3 } locations: - - type: file - target: ../../examples/entities.yaml - - type: file - target: ../../examples/org.yaml - type: file target: ../../examples/all.yaml - - type: file - target: ../../examples/acme-corp.yaml plausible: enabled: true diff --git a/packages/backend/package.json b/packages/backend/package.json index 8b78e12..8684dad 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -64,7 +64,8 @@ "@types/supertest": "^6.0.2", "jose": "^5.6.3", "msw": "^2.3.4", - "supertest": "^7.0.0" + "supertest": "^7.0.0", + "yaml": "^2.2.2" }, "files": [ "dist" diff --git a/packages/backend/src/catalogLocations.test.ts b/packages/backend/src/catalogLocations.test.ts new file mode 100644 index 0000000..db9adf7 --- /dev/null +++ b/packages/backend/src/catalogLocations.test.ts @@ -0,0 +1,31 @@ +import { readFileSync, statSync } from 'node:fs'; +import { resolve } from 'node:path'; +import { ConfigReader } from '@backstage/config'; +import { parse } from 'yaml'; + +const backendDirectory = resolve(__dirname, '..'); +const repositoryDirectory = resolve(backendDirectory, '../..'); + +describe.each(['app-config.example.yaml', 'app-config.production.yaml'])( + '%s catalog locations', + configFile => { + const config = new ConfigReader( + parse(readFileSync(resolve(repositoryDirectory, configFile), 'utf8')), + ); + const fileLocations = config + .getConfigArray('catalog.locations') + .filter(location => location.getString('type') === 'file') + .map(location => location.getString('target')); + + it('loads the aggregate sample catalog', () => { + expect(fileLocations).toContain('../../examples/all.yaml'); + }); + + it.each(fileLocations)('can read the file location %s', target => { + // Backstage resolves file locations from the backend package directory. + const locationPath = resolve(backendDirectory, target); + expect(statSync(locationPath).isFile()).toBe(true); + expect(readFileSync(locationPath, 'utf8').trim()).not.toBe(''); + }); + }, +); diff --git a/yarn.lock b/yarn.lock index 411058e..39c2721 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16701,6 +16701,7 @@ __metadata: pg: "npm:^8.11.3" supertest: "npm:^7.0.0" winston: "npm:^3.2.1" + yaml: "npm:^2.2.2" languageName: unknown linkType: soft