Add catalog model layers with JSON Schema based kind declarations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
```ts
|
||||
import { BasicPermission } from '@backstage/plugin-permission-common';
|
||||
import { CatalogModelLayer } from '@backstage/catalog-model/alpha';
|
||||
import { ResourcePermission } from '@backstage/plugin-permission-common';
|
||||
|
||||
// @alpha
|
||||
@@ -50,6 +51,9 @@ export const taskReadPermission: ResourcePermission<'scaffolder-task'>;
|
||||
// @alpha
|
||||
export const templateManagementPermission: BasicPermission;
|
||||
|
||||
// @alpha
|
||||
export const templateModelLayer: CatalogModelLayer;
|
||||
|
||||
// @alpha
|
||||
export const templateParameterReadPermission: ResourcePermission<'scaffolder-template'>;
|
||||
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
|
||||
export * from './permissions';
|
||||
export { templateModelLayer } from './catalogModel';
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2026 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.
|
||||
*/
|
||||
|
||||
import { createCatalogModelLayer } from '@backstage/catalog-model/alpha';
|
||||
import schema from './Template.v1beta3.schema.json';
|
||||
|
||||
/**
|
||||
* Extends the catalog model with the Template kind.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const templateModelLayer = createCatalogModelLayer({
|
||||
layerId: 'Template',
|
||||
builder: model => {
|
||||
model.addKind({
|
||||
group: 'scaffolder.backstage.io',
|
||||
names: {
|
||||
kind: 'Template',
|
||||
singular: 'template',
|
||||
plural: 'templates',
|
||||
},
|
||||
description: 'A template for scaffolding a new component',
|
||||
versions: [
|
||||
{
|
||||
name: 'v1beta3',
|
||||
relationFields: [
|
||||
{
|
||||
selector: { path: 'spec.owner' },
|
||||
relation: 'ownedBy',
|
||||
defaultKind: 'Group',
|
||||
// TODO: This was inherit since before, but should ownership in general be default instead?
|
||||
defaultNamespace: 'inherit',
|
||||
allowedKinds: ['Group', 'User'],
|
||||
},
|
||||
],
|
||||
schema: {
|
||||
jsonSchema: schema as any,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user