Merge pull request #9761 from backstage/jhaals/remove-githuborg-providers
catalog-backend: Remove `processors.githubOrg` config section
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Removed the `processors.githubOrg` config section which is unused and has been replaced by the integrations config.
|
||||
@@ -211,14 +211,6 @@ catalog:
|
||||
- Location
|
||||
|
||||
processors:
|
||||
githubOrg:
|
||||
providers:
|
||||
- target: https://github.com
|
||||
token: ${GITHUB_TOKEN}
|
||||
#### Example for how to add your GitHub Enterprise instance using the API:
|
||||
# - target: https://ghe.example.net
|
||||
# apiBaseUrl: https://ghe.example.net/api
|
||||
# token: ${GHE_TOKEN}
|
||||
ldapOrg:
|
||||
### Example for how to add your enterprise LDAP server
|
||||
# providers:
|
||||
|
||||
Vendored
-33
@@ -110,39 +110,6 @@ export interface Config {
|
||||
* List of processor-specific options and attributes
|
||||
*/
|
||||
processors?: {
|
||||
/**
|
||||
* GithubOrgReaderProcessor configuration
|
||||
*
|
||||
* @deprecated Configure a GitHub integration instead.
|
||||
*/
|
||||
githubOrg?: {
|
||||
/**
|
||||
* The configuration parameters for each single GitHub org provider.
|
||||
*/
|
||||
providers: Array<{
|
||||
/**
|
||||
* The prefix of the target that this matches on, e.g.
|
||||
* "https://github.com", with no trailing slash.
|
||||
*/
|
||||
target: string;
|
||||
/**
|
||||
* The base URL of the API of this provider, e.g.
|
||||
* "https://api.github.com", with no trailing slash.
|
||||
*
|
||||
* May be omitted specifically for GitHub; then it will be deduced.
|
||||
*/
|
||||
apiBaseUrl?: string;
|
||||
/**
|
||||
* The authorization token to use for requests to this provider.
|
||||
*
|
||||
* If no token is specified, anonymous access is used.
|
||||
*
|
||||
* @visibility secret
|
||||
*/
|
||||
token?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
/**
|
||||
* GithubMultiOrgReaderProcessor configuration
|
||||
*/
|
||||
|
||||
@@ -15,68 +15,9 @@
|
||||
*/
|
||||
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { readGithubConfig, readGithubMultiOrgConfig } from './config';
|
||||
import { readGithubMultiOrgConfig } from './config';
|
||||
|
||||
describe('config', () => {
|
||||
describe('readGithubConfig', () => {
|
||||
function config(
|
||||
providers: { target: string; apiBaseUrl?: string; token?: string }[],
|
||||
) {
|
||||
return new ConfigReader({
|
||||
catalog: { processors: { githubOrg: { providers } } },
|
||||
});
|
||||
}
|
||||
|
||||
it('adds a default GitHub entry when missing', () => {
|
||||
const output = readGithubConfig(config([]));
|
||||
expect(output).toEqual([
|
||||
{
|
||||
target: 'https://github.com',
|
||||
apiBaseUrl: 'https://api.github.com',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('injects the correct GitHub API base URL when missing', () => {
|
||||
const output = readGithubConfig(
|
||||
config([{ target: 'https://github.com' }]),
|
||||
);
|
||||
expect(output).toEqual([
|
||||
{
|
||||
target: 'https://github.com',
|
||||
apiBaseUrl: 'https://api.github.com',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('rejects custom targets with no base URLs', () => {
|
||||
expect(() =>
|
||||
readGithubConfig(config([{ target: 'https://ghe.company.com' }])),
|
||||
).toThrow(
|
||||
'Provider at https://ghe.company.com must configure an explicit apiBaseUrl',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects funky configs', () => {
|
||||
expect(() => readGithubConfig(config([{ target: 7 } as any]))).toThrow(
|
||||
/target/,
|
||||
);
|
||||
expect(() =>
|
||||
readGithubConfig(config([{ noTarget: '7' } as any])),
|
||||
).toThrow(/target/);
|
||||
expect(() =>
|
||||
readGithubConfig(
|
||||
config([{ target: 'https://github.com', apiBaseUrl: 7 } as any]),
|
||||
),
|
||||
).toThrow(/apiBaseUrl/);
|
||||
expect(() =>
|
||||
readGithubConfig(
|
||||
config([{ target: 'https://github.com', token: 7 } as any]),
|
||||
),
|
||||
).toThrow(/token/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('readGithubMultiOrgConfig', () => {
|
||||
function config(
|
||||
orgs: { name: string; groupNamespace?: string; userNamespace?: string }[],
|
||||
|
||||
@@ -15,74 +15,6 @@
|
||||
*/
|
||||
|
||||
import { Config } from '@backstage/config';
|
||||
import { trimEnd } from 'lodash';
|
||||
|
||||
/**
|
||||
* The configuration parameters for a single GitHub API provider.
|
||||
*/
|
||||
export type ProviderConfig = {
|
||||
/**
|
||||
* The prefix of the target that this matches on, e.g. "https://github.com",
|
||||
* with no trailing slash.
|
||||
*/
|
||||
target: string;
|
||||
|
||||
/**
|
||||
* The base URL of the API of this provider, e.g. "https://api.github.com",
|
||||
* with no trailing slash.
|
||||
*
|
||||
* May be omitted specifically for GitHub; then it will be deduced.
|
||||
*/
|
||||
apiBaseUrl?: string;
|
||||
|
||||
/**
|
||||
* The authorization token to use for requests to this provider.
|
||||
*
|
||||
* If no token is specified, anonymous access is used.
|
||||
*/
|
||||
token?: string;
|
||||
};
|
||||
|
||||
// TODO(freben): Break out common code and config from here and GithubReaderProcessor
|
||||
export function readGithubConfig(config: Config): ProviderConfig[] {
|
||||
const providers: ProviderConfig[] = [];
|
||||
|
||||
const providerConfigs =
|
||||
config.getOptionalConfigArray('catalog.processors.githubOrg.providers') ??
|
||||
[];
|
||||
|
||||
// First read all the explicit providers
|
||||
for (const providerConfig of providerConfigs) {
|
||||
const target = trimEnd(providerConfig.getString('target'), '/');
|
||||
let apiBaseUrl = providerConfig.getOptionalString('apiBaseUrl');
|
||||
const token = providerConfig.getOptionalString('token');
|
||||
|
||||
if (apiBaseUrl) {
|
||||
apiBaseUrl = trimEnd(apiBaseUrl, '/');
|
||||
} else if (target === 'https://github.com') {
|
||||
apiBaseUrl = 'https://api.github.com';
|
||||
}
|
||||
|
||||
if (!apiBaseUrl) {
|
||||
throw new Error(
|
||||
`Provider at ${target} must configure an explicit apiBaseUrl`,
|
||||
);
|
||||
}
|
||||
|
||||
providers.push({ target, apiBaseUrl, token });
|
||||
}
|
||||
|
||||
// If no explicit github.com provider was added, put one in the list as
|
||||
// a convenience
|
||||
if (!providers.some(p => p.target === 'https://github.com')) {
|
||||
providers.push({
|
||||
target: 'https://github.com',
|
||||
apiBaseUrl: 'https://api.github.com',
|
||||
});
|
||||
}
|
||||
|
||||
return providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* The configuration parameters for a multi-org GitHub processor.
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { readGithubConfig, readGithubMultiOrgConfig } from './config';
|
||||
export type { GithubMultiOrgConfig, ProviderConfig } from './config';
|
||||
export { readGithubMultiOrgConfig } from './config';
|
||||
export type { GithubMultiOrgConfig } from './config';
|
||||
export {
|
||||
getOrganizationRepositories,
|
||||
getOrganizationTeams,
|
||||
|
||||
@@ -746,36 +746,6 @@
|
||||
"description": "List of processor-specific options and attributes",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"githubOrg": {
|
||||
"description": "GithubOrgReaderProcessor configuration",
|
||||
"type": "object",
|
||||
"required": ["providers"],
|
||||
"properties": {
|
||||
"providers": {
|
||||
"description": "The configuration parameters for each single GitHub org provider.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["target"],
|
||||
"properties": {
|
||||
"target": {
|
||||
"description": "The prefix of the target that this matches on, e.g.\n\"https://github.com\", with no trailing slash.",
|
||||
"type": "string"
|
||||
},
|
||||
"apiBaseUrl": {
|
||||
"description": "The base URL of the API of this provider, e.g.\n\"https://api.github.com\", with no trailing slash.\n\nMay be omitted specifically for GitHub; then it will be deduced.",
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"description": "The authorization token to use for requests to this provider.\n\nIf no token is specified, anonymous access is used.",
|
||||
"visibility": "secret",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ldapOrg": {
|
||||
"description": "LdapOrgReaderProcessor configuration",
|
||||
"type": "object",
|
||||
|
||||
Reference in New Issue
Block a user