Updated permission rule descriptions with a couple of fixes, grammar improvements and consistency

Signed-off-by: Harry Hogg <hhogg@spotify.com>
This commit is contained in:
Harry Hogg
2023-02-08 13:43:39 +00:00
parent 5bc2d9f739
commit a32da1e381
6 changed files with 9 additions and 10 deletions
@@ -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
@@ -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'),
@@ -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),
@@ -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
@@ -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
@@ -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] }),