Set group as optional parameter. Scan everything if not present
Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
'@backstage/plugin-catalog-backend-module-gitlab': minor
|
||||
---
|
||||
|
||||
Add the possibility in the `GitlabDiscoveryEntityProvider` to scan the whole project instead of concrete groups. For that, use a configuration like this one:
|
||||
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:
|
||||
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`
|
||||
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,22 +22,10 @@ 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`
|
||||
```
|
||||
|
||||
If you desire so, it's also possible to execute the gitlab discovery in your entire
|
||||
project. In order to do that, use this catalog configuration instead:
|
||||
|
||||
```yaml
|
||||
catalog:
|
||||
providers:
|
||||
gitlab:
|
||||
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`
|
||||
```
|
||||
|
||||
As this provider is not one of the default providers, you will first need to install
|
||||
the gitlab catalog plugin:
|
||||
|
||||
|
||||
+28
-47
@@ -23,53 +23,34 @@ export interface Config {
|
||||
/**
|
||||
* GitlabDiscoveryEntityProvider configuration
|
||||
*/
|
||||
gitlab?:
|
||||
| {
|
||||
/**
|
||||
* (Required) Gitlab's host name.
|
||||
* @visibility backend
|
||||
*/
|
||||
host: string;
|
||||
/**
|
||||
* (Optional) Default branch to read the catalog-info.yaml file.
|
||||
* If not set, 'master' will be used.
|
||||
* @visibility backend
|
||||
*/
|
||||
branch?: string;
|
||||
/**
|
||||
* (Optional) The name used for the catalog file.
|
||||
* If not set, 'catalog-info.yaml' will be used.
|
||||
* @visibility backend
|
||||
*/
|
||||
entityFilename?: string;
|
||||
}
|
||||
| Record<
|
||||
string,
|
||||
{
|
||||
/**
|
||||
* (Required) Gitlab's host name.
|
||||
* @visibility backend
|
||||
*/
|
||||
host: string;
|
||||
/**
|
||||
* (Required) Gitlab's group[/subgroup] where the discovery is done.
|
||||
* @visibility backend
|
||||
*/
|
||||
group: string;
|
||||
/**
|
||||
* (Optional) Default branch to read the catalog-info.yaml file.
|
||||
* If not set, 'master' will be used.
|
||||
* @visibility backend
|
||||
*/
|
||||
branch?: string;
|
||||
/**
|
||||
* (Optional) The name used for the catalog file.
|
||||
* If not set, 'catalog-info.yaml' will be used.
|
||||
* @visibility backend
|
||||
*/
|
||||
entityFilename?: string;
|
||||
}
|
||||
>;
|
||||
gitlab?: Record<
|
||||
string,
|
||||
{
|
||||
/**
|
||||
* (Required) Gitlab's host name.
|
||||
* @visibility backend
|
||||
*/
|
||||
host: string;
|
||||
/**
|
||||
* (Optional) Gitlab's group[/subgroup] where the discovery is done.
|
||||
* If not defined the whole project will be scanned.
|
||||
* @visibility backend
|
||||
*/
|
||||
group?: string;
|
||||
/**
|
||||
* (Optional) Default branch to read the catalog-info.yaml file.
|
||||
* If not set, 'master' will be used.
|
||||
* @visibility backend
|
||||
*/
|
||||
branch?: string;
|
||||
/**
|
||||
* (Optional) The name used for the catalog file.
|
||||
* If not set, 'catalog-info.yaml' will be used.
|
||||
* @visibility backend
|
||||
*/
|
||||
entityFilename?: string;
|
||||
}
|
||||
>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ 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'",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -109,8 +109,10 @@ describe('config', () => {
|
||||
catalog: {
|
||||
providers: {
|
||||
gitlab: {
|
||||
host: 'host',
|
||||
branch: 'main',
|
||||
test: {
|
||||
host: 'host',
|
||||
branch: 'main',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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 =
|
||||
@@ -48,7 +48,6 @@ function readGitlabConfig(id: string, config: Config): GitlabProviderConfig {
|
||||
* @param config - The config object to extract from
|
||||
*/
|
||||
export function readGitlabConfigs(config: Config): GitlabProviderConfig[] {
|
||||
const reservedParams = ['host', 'group', 'branch', 'catalogFile'];
|
||||
const configs: GitlabProviderConfig[] = [];
|
||||
|
||||
const providerConfigs = config.getOptionalConfig('catalog.providers.gitlab');
|
||||
@@ -57,20 +56,8 @@ export function readGitlabConfigs(config: Config): GitlabProviderConfig[] {
|
||||
return configs;
|
||||
}
|
||||
|
||||
if (providerConfigs.keys().some(r => reservedParams.indexOf(r) >= 0)) {
|
||||
configs.push({
|
||||
id: 'full-check',
|
||||
group: '',
|
||||
branch: providerConfigs.getOptionalString('branch') ?? 'master',
|
||||
host: providerConfigs.getString('host'),
|
||||
catalogFile:
|
||||
providerConfigs.getOptionalString('entityFilename') ??
|
||||
'catalog-info.yaml',
|
||||
});
|
||||
} else {
|
||||
for (const id of providerConfigs.keys()) {
|
||||
configs.push(readGitlabConfig(id, providerConfigs.getConfig(id)));
|
||||
}
|
||||
for (const id of providerConfigs.keys()) {
|
||||
configs.push(readGitlabConfig(id, providerConfigs.getConfig(id)));
|
||||
}
|
||||
|
||||
return configs;
|
||||
|
||||
Reference in New Issue
Block a user