catalog-github: defaultNamespace to alwaysUseDefaultNamespace

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2024-05-13 12:45:28 +02:00
parent 4cd526e1ea
commit 207f962461
5 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -2,6 +2,6 @@
'@backstage/plugin-catalog-backend-module-github': patch
---
Added `defaultNamespace` option to `GithubMultiOrgEntityProvider`.
Added `alwaysUseDefaultNamespace` option to `GithubMultiOrgEntityProvider`.
If set to true, the provider will use `default` as the namespace for all group entities. Groups with the same name across different orgs will be considered the same group.
@@ -120,7 +120,7 @@ export const catalogModuleGithubOrgEntityProvider = createBackendModule({
logger,
userTransformer,
teamTransformer,
defaultNamespace:
alwaysUseDefaultNamespace:
definitions.length === 1 && definition.orgs?.length === 1,
}),
);
@@ -150,7 +150,7 @@ export class GithubMultiOrgEntityProvider implements EntityProvider {
orgs?: string[];
userTransformer?: UserTransformer;
teamTransformer?: TeamTransformer;
defaultNamespace?: boolean;
alwaysUseDefaultNamespace?: boolean;
});
// (undocumented)
connect(connection: EntityProviderConnection): Promise<void>;
@@ -166,7 +166,7 @@ export class GithubMultiOrgEntityProvider implements EntityProvider {
// @public
export interface GithubMultiOrgEntityProviderOptions {
defaultNamespace?: boolean;
alwaysUseDefaultNamespace?: boolean;
events?: EventsService;
githubCredentialsProvider?: GithubCredentialsProvider;
githubUrl: string;
@@ -647,7 +647,7 @@ describe('GithubMultiOrgEntityProvider', () => {
});
});
it('should use the default namespace if options.defaultNamespace is provided', async () => {
it('should use the default namespace if options.alwaysUseDefaultNamespace is provided', async () => {
mockClient
.mockResolvedValueOnce({
organization: {
@@ -764,7 +764,7 @@ describe('GithubMultiOrgEntityProvider', () => {
githubUrl: 'https://github.com',
logger,
orgs: ['orgA', 'orgB'],
defaultNamespace: true,
alwaysUseDefaultNamespace: true,
});
await entityProvider.connect(entityProviderConnection);
@@ -150,7 +150,7 @@ export interface GithubMultiOrgEntityProviderOptions {
*
* If set to true, groups with the same name across different orgs will be considered the same group.
*/
defaultNamespace?: boolean;
alwaysUseDefaultNamespace?: boolean;
/**
* Optionally include a user transformer for transforming from GitHub users to User Entities
@@ -207,7 +207,7 @@ export class GithubMultiOrgEntityProvider implements EntityProvider {
userTransformer: options.userTransformer,
teamTransformer: options.teamTransformer,
events: options.events,
defaultNamespace: options.defaultNamespace,
alwaysUseDefaultNamespace: options.alwaysUseDefaultNamespace,
});
provider.schedule(options.schedule);
@@ -226,7 +226,7 @@ export class GithubMultiOrgEntityProvider implements EntityProvider {
orgs?: string[];
userTransformer?: UserTransformer;
teamTransformer?: TeamTransformer;
defaultNamespace?: boolean;
alwaysUseDefaultNamespace?: boolean;
},
) {}
@@ -857,7 +857,7 @@ export class GithubMultiOrgEntityProvider implements EntityProvider {
const result = await defaultOrganizationTeamTransformer(team, ctx);
if (result && result.spec) {
if (!this.options.defaultNamespace) {
if (!this.options.alwaysUseDefaultNamespace) {
result.metadata.namespace = ctx.org.toLocaleLowerCase('en-US');
}