Merge pull request #12050 from ivangonzalezacuna/feature/gitlab-entity-provider-scan-full-project
[GitlabDiscoveryEntityProvider] Add possibility to scan all the groups in the project
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-gitlab': patch
|
||||
---
|
||||
|
||||
Add the possibility in the `GitlabDiscoveryEntityProvider` to scan the whole project instead of concrete groups. For that, use a configuration like this one, where the group parameter is omitted (not mandatory anymore):
|
||||
|
||||
```yaml
|
||||
catalog:
|
||||
providers:
|
||||
gitlab:
|
||||
yourProviderId:
|
||||
host: gitlab-host # Identifies one of the hosts set up in the integrations
|
||||
branch: main # Optional. Uses `master` as default
|
||||
entityFilename: catalog-info.yaml # Optional. Defaults to `catalog-info.yaml`
|
||||
```
|
||||
@@ -22,7 +22,7 @@ catalog:
|
||||
yourProviderId:
|
||||
host: gitlab-host # Identifies one of the hosts set up in the integrations
|
||||
branch: main # Optional. Uses `master` as default
|
||||
group: example-group # Group and subgroup (if needed) to look for repositories
|
||||
group: example-group # Optional. Group and subgroup (if needed) to look for repositories. If not present the whole project will be scanned
|
||||
entityFilename: catalog-info.yaml # Optional. Defaults to `catalog-info.yaml`
|
||||
```
|
||||
|
||||
|
||||
+3
-2
@@ -32,10 +32,11 @@ export interface Config {
|
||||
*/
|
||||
host: string;
|
||||
/**
|
||||
* (Required) Gitlab's group[/subgroup] where the discovery is done.
|
||||
* (Optional) Gitlab's group[/subgroup] where the discovery is done.
|
||||
* If not defined the whole project will be scanned.
|
||||
* @visibility backend
|
||||
*/
|
||||
group: string;
|
||||
group?: string;
|
||||
/**
|
||||
* (Optional) Default branch to read the catalog-info.yaml file.
|
||||
* If not set, 'master' will be used.
|
||||
|
||||
@@ -100,7 +100,26 @@ describe('config', () => {
|
||||
});
|
||||
|
||||
expect(() => readGitlabConfigs(config)).toThrow(
|
||||
"Missing required config value at 'catalog.providers.gitlab.test.group'",
|
||||
"Missing required config value at 'catalog.providers.gitlab.test.host'",
|
||||
);
|
||||
});
|
||||
|
||||
it('read full gitlab project', () => {
|
||||
const config = new ConfigReader({
|
||||
catalog: {
|
||||
providers: {
|
||||
gitlab: {
|
||||
test: {
|
||||
host: 'host',
|
||||
branch: 'main',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const result = readGitlabConfigs(config);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].group).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ import { GitlabProviderConfig } from '../lib/types';
|
||||
* @param config - The config object to extract from
|
||||
*/
|
||||
function readGitlabConfig(id: string, config: Config): GitlabProviderConfig {
|
||||
const group = config.getString('group');
|
||||
const group = config.getOptionalString('group') ?? '';
|
||||
const host = config.getString('host');
|
||||
const branch = config.getOptionalString('branch') ?? 'master';
|
||||
const catalogFile =
|
||||
|
||||
Reference in New Issue
Block a user