diff --git a/.changeset/large-bottles-cheer.md b/.changeset/large-bottles-cheer.md new file mode 100644 index 0000000000..edd62567f5 --- /dev/null +++ b/.changeset/large-bottles-cheer.md @@ -0,0 +1,6 @@ +--- +'@backstage/catalog-model': minor +'@backstage/plugin-catalog-backend': minor +--- + +**BREAKING**: Removed the deprecated `metadata.generation` field entirely. It is no longer present in TS types, nor in the REST API output. Entities that have not yet been re-stitched may still have the field present for some time, but it will get phased out gradually by your catalog instance. diff --git a/.changeset/rich-bobcats-behave.md b/.changeset/rich-bobcats-behave.md new file mode 100644 index 0000000000..d873017624 --- /dev/null +++ b/.changeset/rich-bobcats-behave.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-graphql': patch +--- + +Do not use `metadata.generation` from entity data diff --git a/docs/features/software-catalog/descriptor-format.md b/docs/features/software-catalog/descriptor-format.md index 70a8aeaa51..f0a9db11c5 100644 --- a/docs/features/software-catalog/descriptor-format.md +++ b/docs/features/software-catalog/descriptor-format.md @@ -76,7 +76,6 @@ This is the same entity as returned in JSON from the software catalog API: }, "description": "The place to be, for great artists", "etag": "ZjU2MWRkZWUtMmMxZS00YTZiLWFmMWMtOTE1NGNiZDdlYzNk", - "generation": 1, "labels": { "example.com/custom": "custom_label_value" }, diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 9a65401d55..f1890d6c9d 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -165,7 +165,6 @@ export type EntityLink = { export type EntityMeta = JsonObject & { uid?: string; etag?: string; - generation?: number; name: string; namespace?: string; title?: string; diff --git a/packages/catalog-model/src/entity/Entity.ts b/packages/catalog-model/src/entity/Entity.ts index 029d9e095b..14cd01e40b 100644 --- a/packages/catalog-model/src/entity/Entity.ts +++ b/packages/catalog-model/src/entity/Entity.ts @@ -109,17 +109,6 @@ export type EntityMeta = JsonObject & { */ etag?: string; - /** - * A positive nonzero number that indicates the current generation of data - * for this entity; the value is incremented each time the spec changes. - * - * This field can not be set by the user at creation time, and the server - * will reject an attempt to do so. The field will be populated in read - * operations. - * @deprecated field is not supported. - */ - generation?: number; - /** * The name of the entity. * diff --git a/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.test.ts b/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.test.ts index 3e2639fff9..f32236e977 100644 --- a/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.test.ts +++ b/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.test.ts @@ -28,7 +28,6 @@ describe('FieldFormatEntityPolicy', () => { metadata: uid: e01199ab-08cc-44c2-8e19-5c29ded82521 etag: lsndfkjsndfkjnsdfkjnsd== - generation: 13 name: my-component-yay namespace: the-namespace labels: diff --git a/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts b/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts index 22d0e5e997..18e9523478 100644 --- a/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts +++ b/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts @@ -29,8 +29,7 @@ import { Entity } from '../Entity'; * * @remarks * - * This does not take into account machine generated fields such as uid, etag - * and generation. + * This does not take into account machine generated fields such as uid and etag. * * @public */ diff --git a/packages/catalog-model/src/entity/policies/NoForeignRootFieldsEntityPolicy.test.ts b/packages/catalog-model/src/entity/policies/NoForeignRootFieldsEntityPolicy.test.ts index fb1d703829..f9b5a75c33 100644 --- a/packages/catalog-model/src/entity/policies/NoForeignRootFieldsEntityPolicy.test.ts +++ b/packages/catalog-model/src/entity/policies/NoForeignRootFieldsEntityPolicy.test.ts @@ -28,7 +28,6 @@ describe('NoForeignRootFieldsEntityPolicy', () => { metadata: uid: e01199ab-08cc-44c2-8e19-5c29ded82521 etag: lsndfkjsndfkjnsdfkjnsd== - generation: 13 name: my-component-yay namespace: the-namespace labels: diff --git a/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.test.ts b/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.test.ts index c263689446..4752296ed5 100644 --- a/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.test.ts +++ b/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.test.ts @@ -29,7 +29,6 @@ describe('SchemaValidEntityPolicy', () => { metadata: uid: e01199ab-08cc-44c2-8e19-5c29ded82521 etag: lsndfkjsndfkjnsdfkjnsd== - generation: 13 name: my-component-yay namespace: the-namespace labels: @@ -127,26 +126,6 @@ describe('SchemaValidEntityPolicy', () => { await expect(policy.enforce(data)).rejects.toThrow(/etag/); }); - it('accepts missing generation', async () => { - delete data.metadata.generation; - await expect(policy.enforce(data)).resolves.toBe(data); - }); - - it('rejects bad generation type', async () => { - data.metadata.generation = 'a'; - await expect(policy.enforce(data)).rejects.toThrow(/generation/); - }); - - it('rejects zero generation', async () => { - data.metadata.generation = 0; - await expect(policy.enforce(data)).rejects.toThrow(/generation/); - }); - - it('rejects non-integer generation', async () => { - data.metadata.generation = 1.5; - await expect(policy.enforce(data)).rejects.toThrow(/generation/); - }); - it('rejects missing name', async () => { delete data.metadata.name; await expect(policy.enforce(data)).rejects.toThrow(/name/); diff --git a/packages/catalog-model/src/schema/EntityMeta.schema.json b/packages/catalog-model/src/schema/EntityMeta.schema.json index 7b2b9d3f82..cfdf9539c2 100644 --- a/packages/catalog-model/src/schema/EntityMeta.schema.json +++ b/packages/catalog-model/src/schema/EntityMeta.schema.json @@ -6,7 +6,6 @@ { "uid": "e01199ab-08cc-44c2-8e19-5c29ded82521", "etag": "lsndfkjsndfkjnsdfkjnsd==", - "generation": 13, "name": "my-component-yay", "namespace": "the-namespace", "labels": { @@ -34,13 +33,6 @@ "examples": ["lsndfkjsndfkjnsdfkjnsd=="], "minLength": 1 }, - "generation": { - "type": "integer", - "description": "A positive nonzero number that indicates the current generation of data for this entity; the value is incremented each time the spec changes. This field can not be set by the user at creation time, and the server will reject an attempt to do so. The field will be populated in read operations.", - "examples": [1], - "minimum": 1, - "deprecated": true - }, "name": { "type": "string", "description": "The name of the entity. Must be unique within the catalog at any given point in time, for any given namespace + kind pair.", diff --git a/packages/catalog-model/src/validation/entityKindSchemaValidator.test.ts b/packages/catalog-model/src/validation/entityKindSchemaValidator.test.ts index f954a2388c..ee8f39b140 100644 --- a/packages/catalog-model/src/validation/entityKindSchemaValidator.test.ts +++ b/packages/catalog-model/src/validation/entityKindSchemaValidator.test.ts @@ -28,7 +28,6 @@ describe('entityKindSchemaValidator', () => { metadata: { uid: 'e01199ab-08cc-44c2-8e19-5c29ded82521', etag: 'lsndfkjsndfkjnsdfkjnsd==', - generation: 13, name: 'test', namespace: 'ns', labels: { diff --git a/packages/catalog-model/src/validation/entitySchemaValidator.test.ts b/packages/catalog-model/src/validation/entitySchemaValidator.test.ts index b486de1df2..12f890d9db 100644 --- a/packages/catalog-model/src/validation/entitySchemaValidator.test.ts +++ b/packages/catalog-model/src/validation/entitySchemaValidator.test.ts @@ -27,7 +27,6 @@ describe('entitySchemaValidator', () => { metadata: { uid: 'e01199ab-08cc-44c2-8e19-5c29ded82521', etag: 'lsndfkjsndfkjnsdfkjnsd==', - generation: 13, name: 'test', namespace: 'ns', title: 'My Component, Yay', @@ -154,26 +153,6 @@ describe('entitySchemaValidator', () => { expect(() => validator(entity)).toThrow(/etag/); }); - it('accepts missing generation', () => { - delete entity.metadata.generation; - expect(() => validator(entity)).not.toThrow(); - }); - - it('rejects bad generation type', () => { - entity.metadata.generation = 'a'; - expect(() => validator(entity)).toThrow(/generation/); - }); - - it('rejects zero generation', () => { - entity.metadata.generation = 0; - expect(() => validator(entity)).toThrow(/generation/); - }); - - it('rejects non-integer generation', () => { - entity.metadata.generation = 1.5; - expect(() => validator(entity)).toThrow(/generation/); - }); - it('rejects missing name', () => { delete entity.metadata.name; expect(() => validator(entity)).toThrow(/name/); diff --git a/plugins/catalog-backend/src/stitching/Stitcher.test.ts b/plugins/catalog-backend/src/stitching/Stitcher.test.ts index 9df4bedd60..582ed3f953 100644 --- a/plugins/catalog-backend/src/stitching/Stitcher.test.ts +++ b/plugins/catalog-backend/src/stitching/Stitcher.test.ts @@ -107,7 +107,6 @@ describe('Stitcher', () => { name: 'n', namespace: 'ns', etag: expect.any(String), - generation: 1, uid: 'my-id', }, spec: { @@ -183,7 +182,6 @@ describe('Stitcher', () => { name: 'n', namespace: 'ns', etag: expect.any(String), - generation: 1, uid: 'my-id', }, spec: { diff --git a/plugins/catalog-backend/src/stitching/Stitcher.ts b/plugins/catalog-backend/src/stitching/Stitcher.ts index 37b86fef46..23fdffd272 100644 --- a/plugins/catalog-backend/src/stitching/Stitcher.ts +++ b/plugins/catalog-backend/src/stitching/Stitcher.ts @@ -205,7 +205,6 @@ export class Stitcher { } entity.metadata.uid = entityId; - entity.metadata.generation = 1; if (!entity.metadata.etag) { // If the original data source did not have its own etag handling, // use the hash as a good-quality etag diff --git a/plugins/catalog-backend/src/stitching/buildEntitySearch.test.ts b/plugins/catalog-backend/src/stitching/buildEntitySearch.test.ts index 52e3392676..27b4421a83 100644 --- a/plugins/catalog-backend/src/stitching/buildEntitySearch.test.ts +++ b/plugins/catalog-backend/src/stitching/buildEntitySearch.test.ts @@ -62,7 +62,6 @@ describe('buildEntitySearch', () => { namespace: 'namespace', uid: 'uid', etag: 'etag', - generation: 'generation', c: 'c', }, d: 'd', diff --git a/plugins/catalog-backend/src/stitching/buildEntitySearch.ts b/plugins/catalog-backend/src/stitching/buildEntitySearch.ts index cd8a3735de..54e5ffa738 100644 --- a/plugins/catalog-backend/src/stitching/buildEntitySearch.ts +++ b/plugins/catalog-backend/src/stitching/buildEntitySearch.ts @@ -29,7 +29,6 @@ const SPECIAL_KEYS = [ 'metadata.namespace', 'metadata.uid', 'metadata.etag', - 'metadata.generation', ]; // The maximum length allowed for search values. These columns are indexed, and diff --git a/plugins/catalog-graphql/src/graphql/module.test.ts b/plugins/catalog-graphql/src/graphql/module.test.ts index 605e9d9aed..5490c2030a 100644 --- a/plugins/catalog-graphql/src/graphql/module.test.ts +++ b/plugins/catalog-graphql/src/graphql/module.test.ts @@ -59,7 +59,6 @@ describe('Catalog Module', () => { metadata: { annotations: {}, etag: '123', - generation: 1, labels: {}, name: 'Ben', namespace: 'Blames', @@ -118,7 +117,6 @@ describe('Catalog Module', () => { metadata: { annotations: null as any, etag: '123', - generation: 1, labels: {}, name: 'Ben', namespace: 'Blames', @@ -170,7 +168,6 @@ describe('Catalog Module', () => { metadata: { annotations: {}, etag: '123', - generation: 1, labels: null as any, name: 'Ben', namespace: 'Blames', @@ -221,7 +218,6 @@ describe('Catalog Module', () => { metadata: { annotations: { lob: 'bloben' }, etag: '123', - generation: 1, labels: {}, name: 'Ben', namespace: 'Blames', @@ -272,7 +268,6 @@ describe('Catalog Module', () => { metadata: { annotations: {}, etag: '123', - generation: 1, labels: { lob2: 'bloben' }, name: 'Ben', namespace: 'Blames', diff --git a/plugins/catalog-graphql/src/graphql/types.ts b/plugins/catalog-graphql/src/graphql/types.ts index 4dc5a3522b..aecf2a1cd1 100644 --- a/plugins/catalog-graphql/src/graphql/types.ts +++ b/plugins/catalog-graphql/src/graphql/types.ts @@ -70,7 +70,6 @@ export type ComponentMetadata = EntityMetadata & { annotation?: Maybe; annotations: Scalars['JSONObject']; etag: Scalars['String']; - generation: Scalars['Int']; label?: Maybe; labels: Scalars['JSONObject']; name: Scalars['String']; @@ -91,7 +90,6 @@ export type DefaultEntityMetadata = EntityMetadata & { annotation?: Maybe; annotations: Scalars['JSONObject']; etag: Scalars['String']; - generation: Scalars['Int']; label?: Maybe; labels: Scalars['JSONObject']; name: Scalars['String']; @@ -115,7 +113,6 @@ export type EntityMetadata = { annotation?: Maybe; annotations: Scalars['JSONObject']; etag: Scalars['String']; - generation: Scalars['Int']; label?: Maybe; labels: Scalars['JSONObject']; name: Scalars['String']; @@ -153,7 +150,6 @@ export type TemplateMetadata = EntityMetadata & { annotation?: Maybe; annotations: Scalars['JSONObject']; etag: Scalars['String']; - generation: Scalars['Int']; label?: Maybe; labels: Scalars['JSONObject']; name: Scalars['String']; @@ -386,7 +382,6 @@ export type ComponentMetadataResolvers< >; annotations?: Resolver; etag?: Resolver; - generation?: Resolver; label?: Resolver< Maybe, ParentType, @@ -416,7 +411,6 @@ export type DefaultEntityMetadataResolvers< >; annotations?: Resolver; etag?: Resolver; - generation?: Resolver; label?: Resolver< Maybe, ParentType, @@ -454,7 +448,6 @@ export type EntityMetadataResolvers< >; annotations?: Resolver; etag?: Resolver; - generation?: Resolver; label?: Resolver< Maybe, ParentType, @@ -517,7 +510,6 @@ export type TemplateMetadataResolvers< >; annotations?: Resolver; etag?: Resolver; - generation?: Resolver; label?: Resolver< Maybe, ParentType, diff --git a/plugins/catalog-graphql/src/schema.js b/plugins/catalog-graphql/src/schema.js index 6690f34da6..cf6ccf3017 100644 --- a/plugins/catalog-graphql/src/schema.js +++ b/plugins/catalog-graphql/src/schema.js @@ -26,7 +26,6 @@ const schema = /* GraphQL */ ` label(name: String!): JSON uid: String! etag: String! - generation: Int! } type DefaultEntityMetadata implements EntityMetadata { @@ -37,7 +36,6 @@ const schema = /* GraphQL */ ` label(name: String!): JSON uid: String! etag: String! - generation: Int! } type ComponentMetadata implements EntityMetadata { @@ -48,7 +46,6 @@ const schema = /* GraphQL */ ` label(name: String!): JSON uid: String! etag: String! - generation: Int! # mock field to prove extensions working relationships: String } @@ -61,7 +58,6 @@ const schema = /* GraphQL */ ` label(name: String!): JSON uid: String! etag: String! - generation: Int! # mock field to prove extensions working updatedBy: String } diff --git a/plugins/catalog-graphql/src/service/client.ts b/plugins/catalog-graphql/src/service/client.ts index eaf2e63bc1..c6a5cff140 100644 --- a/plugins/catalog-graphql/src/service/client.ts +++ b/plugins/catalog-graphql/src/service/client.ts @@ -20,7 +20,6 @@ import fetch from 'node-fetch'; export interface ReaderEntityMeta extends EntityMeta { uid: string; etag: string; - generation: number; namespace: string; annotations: Record; labels: Record; diff --git a/plugins/github-deployments/src/mocks/mocks.ts b/plugins/github-deployments/src/mocks/mocks.ts index dc10ccb1c5..3d3abccb92 100644 --- a/plugins/github-deployments/src/mocks/mocks.ts +++ b/plugins/github-deployments/src/mocks/mocks.ts @@ -24,7 +24,6 @@ export const entityStub: { entity: Entity } = { name: 'sample-service', description: 'Sample service', uid: 'g0h33dd9-56h7-835b-b63v-7x5da3j64851', - generation: 1, }, apiVersion: 'backstage.io/v1alpha1', kind: 'Component', diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index afe2c1a1bb..fac4b38e68 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -581,7 +581,7 @@ async function runApiExtraction({ WARNING: Bring a blanket if you're gonna read the code below There's some weird shit going on here, and it's because we cba -forking rushstash to modify the api-documenter markdown generation, +forking rushstack to modify the api-documenter markdown generation, which otherwise is the recommended way to do customizations. */