review comments

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-02-15 14:52:49 +01:00
parent 6fe01cec04
commit 5e585bbc7f
6 changed files with 26 additions and 36 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-common': minor
---
**BREAKING**: Removed the `templateEntityV1beta3Schema` export
@@ -21,7 +21,6 @@ import {
parseEntityRef,
RELATION_OWNED_BY,
RELATION_OWNER_OF,
entityKindSchemaValidator,
} from '@backstage/catalog-model';
import {
CatalogProcessor,
@@ -30,18 +29,16 @@ import {
} from '@backstage/plugin-catalog-backend';
import {
TemplateEntityV1beta3,
templateEntityV1beta3Schema,
templateEntityV1beta3Validator,
} from '@backstage/plugin-scaffolder-common';
/** @public */
export class ScaffolderEntitiesProcessor implements CatalogProcessor {
private readonly validators = [
entityKindSchemaValidator(templateEntityV1beta3Schema),
];
private readonly validators = [templateEntityV1beta3Validator];
async validateEntityKind(entity: Entity): Promise<boolean> {
for (const validator of this.validators) {
if (validator(entity)) {
if (await validator.check(entity)) {
return true;
}
}
+1 -5
View File
@@ -5,7 +5,6 @@
```ts
import { Entity } from '@backstage/catalog-model';
import { JsonObject } from '@backstage/types';
import { JSONSchema } from '@backstage/catalog-model';
import { JsonValue } from '@backstage/types';
import { KindValidator } from '@backstage/catalog-model';
@@ -86,9 +85,6 @@ export interface TemplateEntityV1beta2 extends Entity {
};
}
// @public @deprecated
export const templateEntityV1beta2Schema: JSONSchema;
// @public @deprecated
export const templateEntityV1beta2Validator: KindValidator;
@@ -117,7 +113,7 @@ export interface TemplateEntityV1beta3 extends Entity {
}
// @public
export const templateEntityV1beta3Schema: JSONSchema;
export const templateEntityV1beta3Validator: KindValidator;
// @public
export type TemplateMetadata = {
@@ -17,7 +17,6 @@
import {
Entity,
entityKindSchemaValidator,
JSONSchema,
KindValidator,
} from '@backstage/catalog-model';
import { JsonObject } from '@backstage/types';
@@ -51,18 +50,6 @@ export interface TemplateEntityV1beta2 extends Entity {
const validator = entityKindSchemaValidator(schema);
/**
* JSON schema of the Template kind, apiVersion backstage.io/v1beta2.
*
* @public
* @deprecated Please convert your templates to apiVersion
* scaffolder.backstage.io/v1beta3
*/
export const templateEntityV1beta2Schema: JSONSchema = schema as Omit<
JSONSchema,
'examples'
>;
/**
* Entity data validator for {@link TemplateEntityV1beta2}.
*
@@ -14,9 +14,13 @@
* limitations under the License.
*/
import { Entity, JSONSchema } from '@backstage/catalog-model';
import {
Entity,
entityKindSchemaValidator,
KindValidator,
} from '@backstage/catalog-model';
import { JsonObject } from '@backstage/types';
import v1beta3Schema from './Template.v1beta3.schema.json';
import schema from './Template.v1beta3.schema.json';
/**
* Backstage catalog Template kind Entity. Templates are used by the Scaffolder
@@ -42,12 +46,16 @@ export interface TemplateEntityV1beta3 extends Entity {
};
}
const validator = entityKindSchemaValidator(schema);
/**
* JSON schema of the Template kind, apiVersion scaffolder.backstage.io/v1beta3.
* Entity data validator for {@link TemplateEntityV1beta3}.
*
* @public
*/
export const templateEntityV1beta3Schema: JSONSchema = v1beta3Schema as Omit<
JSONSchema,
'examples'
>;
export const templateEntityV1beta3Validator: KindValidator = {
// TODO(freben): Emulate the old KindValidator until we fix that type
async check(data: Entity) {
return validator(data) === data;
},
};
+2 -5
View File
@@ -21,10 +21,7 @@
*/
export * from './TaskSpec';
export {
templateEntityV1beta2Schema,
templateEntityV1beta2Validator,
} from './TemplateEntityV1beta2';
export { templateEntityV1beta2Validator } from './TemplateEntityV1beta2';
export type { TemplateEntityV1beta2 } from './TemplateEntityV1beta2';
export { templateEntityV1beta3Schema } from './TemplateEntityV1beta3';
export { templateEntityV1beta3Validator } from './TemplateEntityV1beta3';
export type { TemplateEntityV1beta3 } from './TemplateEntityV1beta3';