From a32da1e3811e7617ef6c4e74004f82af6023c846 Mon Sep 17 00:00:00 2001 From: Harry Hogg Date: Wed, 8 Feb 2023 13:43:39 +0000 Subject: [PATCH 1/3] Updated permission rule descriptions with a couple of fixes, grammar improvements and consistency Signed-off-by: Harry Hogg --- .../src/permissions/rules/createPropertyRule.ts | 2 +- .../catalog-backend/src/permissions/rules/hasAnnotation.ts | 3 +-- plugins/catalog-backend/src/permissions/rules/hasLabel.ts | 4 ++-- .../catalog-backend/src/permissions/rules/isEntityKind.ts | 2 +- .../catalog-backend/src/permissions/rules/isEntityOwner.ts | 2 +- plugins/playlist-backend/src/permissions/rules.ts | 6 +++--- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts b/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts index 19a4423846..fd51a1a060 100644 --- a/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts +++ b/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts @@ -22,7 +22,7 @@ import { z } from 'zod'; export const createPropertyRule = (propertyType: 'metadata' | 'spec') => createCatalogPermissionRule({ name: `HAS_${propertyType.toUpperCase()}`, - description: `Allow entities which have the specified ${propertyType} subfield.`, + description: `Allow entities with the specified ${propertyType} subfield`, resourceType: RESOURCE_TYPE_CATALOG_ENTITY, paramsSchema: z.object({ key: z diff --git a/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts b/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts index c24620f41c..ae9b1c3963 100644 --- a/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts +++ b/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts @@ -28,8 +28,7 @@ import { createCatalogPermissionRule } from './util'; */ export const hasAnnotation = createCatalogPermissionRule({ name: 'HAS_ANNOTATION', - description: - 'Allow entities which are annotated with the specified annotation', + description: 'Allow entities with the specified annotation', resourceType: RESOURCE_TYPE_CATALOG_ENTITY, paramsSchema: z.object({ annotation: z.string().describe('Name of the annotation to match on'), diff --git a/plugins/catalog-backend/src/permissions/rules/hasLabel.ts b/plugins/catalog-backend/src/permissions/rules/hasLabel.ts index 376534ca6f..16c5917585 100644 --- a/plugins/catalog-backend/src/permissions/rules/hasLabel.ts +++ b/plugins/catalog-backend/src/permissions/rules/hasLabel.ts @@ -25,10 +25,10 @@ import { createCatalogPermissionRule } from './util'; */ export const hasLabel = createCatalogPermissionRule({ name: 'HAS_LABEL', - description: 'Allow entities which have the specified label metadata.', + description: 'Allow entities with the specified label', resourceType: RESOURCE_TYPE_CATALOG_ENTITY, paramsSchema: z.object({ - label: z.string().describe('Name of the label to match one'), + label: z.string().describe('Name of the label to match on'), }), apply: (resource, { label }) => !!resource.metadata.labels?.hasOwnProperty(label), diff --git a/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts b/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts index eee7a790b2..94aaa63567 100644 --- a/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts +++ b/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts @@ -25,7 +25,7 @@ import { createCatalogPermissionRule } from './util'; */ export const isEntityKind = createCatalogPermissionRule({ name: 'IS_ENTITY_KIND', - description: 'Allow entities with the specified kind', + description: 'Allow entities matching a specified kind', resourceType: RESOURCE_TYPE_CATALOG_ENTITY, paramsSchema: z.object({ kinds: z diff --git a/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts b/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts index c3bfff5c2e..d0cc1d9280 100644 --- a/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts +++ b/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts @@ -27,7 +27,7 @@ import { createCatalogPermissionRule } from './util'; */ export const isEntityOwner = createCatalogPermissionRule({ name: 'IS_ENTITY_OWNER', - description: 'Allow entities owned by the current user', + description: 'Allow entities owned by a specified claim', resourceType: RESOURCE_TYPE_CATALOG_ENTITY, paramsSchema: z.object({ claims: z diff --git a/plugins/playlist-backend/src/permissions/rules.ts b/plugins/playlist-backend/src/permissions/rules.ts index 99f4725972..e29465ed0f 100644 --- a/plugins/playlist-backend/src/permissions/rules.ts +++ b/plugins/playlist-backend/src/permissions/rules.ts @@ -31,10 +31,10 @@ const createPlaylistPermissionRule = makeCreatePermissionRule< const isOwner = createPlaylistPermissionRule({ name: 'IS_OWNER', - description: 'Should allow only if the playlist belongs to the user', + description: 'Allow playlists owned by the given entity refs', resourceType: PLAYLIST_LIST_RESOURCE_TYPE, paramsSchema: z.object({ - owners: z.array(z.string()).describe('List of owner entity refs'), + owners: z.array(z.string()).describe('List of entity refs to match on'), }), apply: (list: PlaylistMetadata, { owners }) => owners.includes(list.owner), toQuery: ({ owners }) => ({ @@ -45,7 +45,7 @@ const isOwner = createPlaylistPermissionRule({ const isPublic = createPlaylistPermissionRule({ name: 'IS_PUBLIC', - description: 'Should allow only if the playlist is public', + description: 'Allow playlists that are set as public', resourceType: PLAYLIST_LIST_RESOURCE_TYPE, apply: (list: PlaylistMetadata) => list.public, toQuery: () => ({ key: 'public', values: [true] }), From b977c2e69ffa4b5c5ce53083fefbb94854521c7d Mon Sep 17 00:00:00 2001 From: Harry Hogg Date: Wed, 8 Feb 2023 13:46:27 +0000 Subject: [PATCH 2/3] Added changeset Signed-off-by: Harry Hogg --- .changeset/brave-lemons-chew.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/brave-lemons-chew.md diff --git a/.changeset/brave-lemons-chew.md b/.changeset/brave-lemons-chew.md new file mode 100644 index 0000000000..61bf7cc6af --- /dev/null +++ b/.changeset/brave-lemons-chew.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-playlist-backend': patch +'@backstage/plugin-catalog-backend': patch +--- + +Minor improvements to the descriptions provided with permission rules schemas From 418bd9234f69fdad46125a698efa0d0a9111ef07 Mon Sep 17 00:00:00 2001 From: Harry Hogg Date: Wed, 8 Feb 2023 13:49:43 +0000 Subject: [PATCH 3/3] Updated tests Signed-off-by: Harry Hogg --- .../src/permissions/rules/createPropertyRule.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-backend/src/permissions/rules/createPropertyRule.test.ts b/plugins/catalog-backend/src/permissions/rules/createPropertyRule.test.ts index 5b34c98ca6..b2630f0f73 100644 --- a/plugins/catalog-backend/src/permissions/rules/createPropertyRule.test.ts +++ b/plugins/catalog-backend/src/permissions/rules/createPropertyRule.test.ts @@ -25,7 +25,7 @@ describe('createPropertyRule', () => { it('formats the rule description correctly', () => { expect(description).toBe( - 'Allow entities which have the specified metadata subfield.', + 'Allow entities with the specified metadata subfield', ); });