removed all references to the removed SCM-specific location types
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
---
|
||||
|
||||
The `CodeOwnersProcessor` no longer supports the deprecated SCM-specific location types like `'github/api'`. This is a breaking change but it is unlikely to have an impact, as these location types haven't been supported by the rest of the catalog for a long time.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-github-deployments': patch
|
||||
---
|
||||
|
||||
The removed `'github'` catalog location type no longer triggers a GitHub integration configuration lookup.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@techdocs/cli': patch
|
||||
'@backstage/techdocs-common': patch
|
||||
---
|
||||
|
||||
Updated usage of `github:` location types in docs to use `url:` instead.
|
||||
@@ -123,7 +123,7 @@ Options:
|
||||
--no-pull Do not pull the latest docker image
|
||||
--no-docker Do not use Docker, use MkDocs executable and plugins in current user environment.
|
||||
--techdocs-ref <HOST_TYPE:URL> The repository hosting documentation source files e.g.
|
||||
github:https://ghe.mycompany.net.com/org/repo.
|
||||
url:https://ghe.mycompany.net.com/org/repo.
|
||||
This value is same as the backstage.io/techdocs-ref annotation of the corresponding
|
||||
Backstage entity.
|
||||
It is completely fine to skip this as it is only being used to set repo_url in mkdocs.yml
|
||||
|
||||
@@ -45,7 +45,7 @@ export function registerCommands(program: CommanderStatic) {
|
||||
)
|
||||
.option(
|
||||
'--techdocs-ref <HOST_TYPE:URL>',
|
||||
'The repository hosting documentation source files e.g. github:https://ghe.mycompany.net.com/org/repo.' +
|
||||
'The repository hosting documentation source files e.g. url:https://ghe.mycompany.net.com/org/repo.' +
|
||||
'\nThis value is same as the backstage.io/techdocs-ref annotation of the corresponding Backstage entity.' +
|
||||
'\nIt is completely fine to skip this as it is only being used to set repo_url in mkdocs.yml if not found.\n',
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ Currently the build process is split up in these three stages.
|
||||
- Generators
|
||||
- Publishers
|
||||
|
||||
Preparers read your entity data and creates a working directory with your documentation source code. For example if you have set your `backstage.io/techdocs-ref` to `github:https://github.com/backstage/backstage.git` it will clone that repository to a temp folder and pass that on to the generator.
|
||||
Preparers read your entity data and creates a working directory with your documentation source code. For example if you have set your `backstage.io/techdocs-ref` to `url:https://github.com/backstage/backstage.git` it will clone that repository to a temp folder and pass that on to the generator.
|
||||
|
||||
Generators takes the prepared source and runs the `techdocs-container` on it. It then passes on the output folder of that build to the publisher.
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('directory preparer', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject when managed-by-location is a git repository', async () => {
|
||||
it('should reject when managed-by-location has an unknown type', async () => {
|
||||
const directoryPreparer = new DirectoryPreparer(
|
||||
mockConfig,
|
||||
logger,
|
||||
@@ -95,12 +95,12 @@ describe('directory preparer', () => {
|
||||
|
||||
const mockEntity = createMockEntity({
|
||||
'backstage.io/managed-by-location':
|
||||
'github:https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
|
||||
'does-not-exist:https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
|
||||
'backstage.io/techdocs-ref': 'dir:./docs',
|
||||
});
|
||||
|
||||
await expect(directoryPreparer.prepare(mockEntity)).rejects.toThrow(
|
||||
/Unable to resolve location type github/,
|
||||
/Unable to resolve location type does-not-exist/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('DefaultApiExplorerPage', () => {
|
||||
] as Entity[],
|
||||
}),
|
||||
getLocationByRef: () =>
|
||||
Promise.resolve({ id: 'id', type: 'github', target: 'url' }),
|
||||
Promise.resolve({ id: 'id', type: 'url', target: 'url' }),
|
||||
getEntityByName: async entityName => {
|
||||
return {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
|
||||
@@ -35,11 +35,11 @@ const entity = {
|
||||
|
||||
const location: Record<string, LocationSpec> = {
|
||||
x: {
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target: 'https://github.com/a/b/blob/master/x.yaml',
|
||||
},
|
||||
y: {
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target: 'https://github.com/a/b/blob/master/y.yaml',
|
||||
},
|
||||
z: {
|
||||
@@ -180,7 +180,7 @@ describe('DefaultCatalogRulesEnforcer', () => {
|
||||
rules: [{ allow: ['user'] }],
|
||||
locations: [
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target: 'https://github.com/a/b/blob/master/x.yaml',
|
||||
rules: [
|
||||
{
|
||||
@@ -204,7 +204,7 @@ describe('DefaultCatalogRulesEnforcer', () => {
|
||||
const enforcer = DefaultCatalogRulesEnforcer.fromConfig(
|
||||
new ConfigReader({
|
||||
catalog: {
|
||||
rules: [{ allow: ['Group'], locations: [{ type: 'github' }] }],
|
||||
rules: [{ allow: ['Group'], locations: [{ type: 'url' }] }],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ const mockCodeOwnersText = () => `
|
||||
describe('CodeOwnersProcessor', () => {
|
||||
const mockLocation = ({
|
||||
basePath = '',
|
||||
type = 'github',
|
||||
type = 'url',
|
||||
} = {}): LocationSpec => ({
|
||||
type,
|
||||
target: `https://github.com/backstage/backstage/blob/master/${basePath}catalog-info.yaml`,
|
||||
|
||||
@@ -27,15 +27,7 @@ import { CatalogProcessor } from './types';
|
||||
|
||||
const ALLOWED_KINDS = ['API', 'Component', 'Domain', 'Resource', 'System'];
|
||||
|
||||
const ALLOWED_LOCATION_TYPES = [
|
||||
'url',
|
||||
'azure/api',
|
||||
'bitbucket/api',
|
||||
'github',
|
||||
'github/api',
|
||||
'gitlab',
|
||||
'gitlab/api',
|
||||
];
|
||||
const ALLOWED_LOCATION_TYPES = ['url'];
|
||||
|
||||
export class CodeOwnersProcessor implements CatalogProcessor {
|
||||
private readonly integrations: ScmIntegrationRegistry;
|
||||
|
||||
@@ -154,7 +154,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: { $text: '../file.txt' } },
|
||||
},
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/backstage/a/b/catalog-info.yaml',
|
||||
},
|
||||
@@ -190,7 +190,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: { $json: './file.json' } },
|
||||
},
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/backstage/a/b/catalog-info.yaml',
|
||||
},
|
||||
@@ -224,7 +224,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: { $yaml: '../file.yaml' } },
|
||||
},
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/backstage/a/b/catalog-info.yaml',
|
||||
},
|
||||
@@ -262,7 +262,7 @@ describe('PlaceholderProcessor', () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/backstage/a/b/catalog-info.yaml',
|
||||
},
|
||||
@@ -300,7 +300,7 @@ describe('PlaceholderProcessor', () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target: './a/b/catalog-info.yaml',
|
||||
},
|
||||
),
|
||||
@@ -340,7 +340,7 @@ describe('PlaceholderProcessor', () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'github',
|
||||
type: 'url',
|
||||
target: './a/b/catalog-info.yaml',
|
||||
},
|
||||
),
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('DefaultCatalogPage', () => {
|
||||
] as Entity[],
|
||||
}),
|
||||
getLocationByRef: () =>
|
||||
Promise.resolve({ id: 'id', type: 'github', target: 'url' }),
|
||||
Promise.resolve({ id: 'id', type: 'url', target: 'url' }),
|
||||
getEntityByName: async entityName => {
|
||||
return {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
|
||||
@@ -28,7 +28,7 @@ const getBaseUrl = (
|
||||
}
|
||||
|
||||
const location = parseLocationRef(host);
|
||||
if (location.type !== 'github' && location.type !== 'url') {
|
||||
if (location.type !== 'url') {
|
||||
return 'https://api.github.com';
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ describe('github-deployments', () => {
|
||||
entity.entity.metadata.annotations = {
|
||||
'github.com/project-slug': 'org/repo',
|
||||
'backstage.io/source-location':
|
||||
'github:https://my-github-1.com/org/repo/tree/master/',
|
||||
'url:https://my-github-1.com/org/repo/tree/master/',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -276,7 +276,7 @@ describe('github-deployments', () => {
|
||||
entity.entity.metadata.annotations = {
|
||||
'github.com/project-slug': 'org/repo',
|
||||
'backstage.io/managed-by-location':
|
||||
'github:https://my-github-2.com/org/repo/blob/master/catalog-info.yaml',
|
||||
'url:https://my-github-2.com/org/repo/blob/master/catalog-info.yaml',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('github-deployments', () => {
|
||||
entity.entity.metadata.annotations = {
|
||||
'github.com/project-slug': 'org/repo',
|
||||
'backstage.io/managed-by-location':
|
||||
'github:https://my-github-3.com/org/repo/blob/master/catalog-info.yaml',
|
||||
'url:https://my-github-3.com/org/repo/blob/master/catalog-info.yaml',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -323,7 +323,7 @@ describe('github-deployments', () => {
|
||||
entity.entity.metadata.annotations = {
|
||||
'github.com/project-slug': 'org/repo',
|
||||
'backstage.io/managed-by-location':
|
||||
'github:https://my-github-unknown.com/org/repo/blob/master/catalog-info.yaml',
|
||||
'url:https://my-github-unknown.com/org/repo/blob/master/catalog-info.yaml',
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
* Copyright 2020 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// This is a script that helps you migrate any locations that are using
|
||||
// deprecated location types. Change the below URL to point towards your
|
||||
// catalog API endpoint and execute the script. It will delete and add
|
||||
// back the locations with the correct type one by one.
|
||||
|
||||
const BASE_URL = 'http://localhost:7007/api/catalog'; // Change me
|
||||
|
||||
const deprecatedTypes = [
|
||||
'github',
|
||||
'github/api',
|
||||
'bitbucket/api',
|
||||
'gitlab/api',
|
||||
'azure/api',
|
||||
];
|
||||
|
||||
async function main() {
|
||||
const locations = await request('GET', `${BASE_URL}/locations`);
|
||||
|
||||
for (const { data: location } of locations) {
|
||||
if (!deprecatedTypes.includes(location.type)) {
|
||||
continue;
|
||||
}
|
||||
console.log(`${location.type} -> url : ${location.target}`);
|
||||
await request('DELETE', `${BASE_URL}/locations/${location.id}`);
|
||||
try {
|
||||
await request('POST', `${BASE_URL}/locations`, {
|
||||
type: 'url',
|
||||
target: location.target,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(`Failed to add back location ${location.target}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function request(method, url, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const parsedUrl = require('url').parse(url);
|
||||
|
||||
const req = require('http').request(
|
||||
{
|
||||
method,
|
||||
...parsedUrl,
|
||||
headers: body
|
||||
? {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
: {},
|
||||
},
|
||||
res => {
|
||||
const chunks = [];
|
||||
res.on('data', chunk => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
if (res.statusCode >= 300) {
|
||||
reject(
|
||||
new Error(
|
||||
`${method} to ${url} failed with status ${res.statusCode}`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const responseBody = Buffer.concat(chunks).toString('utf8').trim();
|
||||
if (responseBody) {
|
||||
resolve(JSON.parse(responseBody));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
req.on('error', reject);
|
||||
|
||||
if (body) {
|
||||
req.write(JSON.stringify(body));
|
||||
}
|
||||
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
console.error(error.stack);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user