Reworked permission rules and filtering to follow similar pattern to catalog

Signed-off-by: Harry Hogg <hhogg@spotify.com>
Co-authored-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Harry Hogg
2023-01-12 12:11:18 +00:00
committed by Vincenzo Scamporlino
parent f8540c1049
commit 277847e064
11 changed files with 153 additions and 178 deletions
@@ -55,13 +55,7 @@ export interface TemplateEntityV1beta3 extends Entity {
* A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying
* javascript action and some optional input parameters that may or may not have been collected from the end user.
*/
steps: Array<{
id?: string;
name?: string;
action: string;
input?: JsonObject;
if?: string | boolean;
}>;
steps: Array<TemplateEntityStepV1beta3>;
/**
* The output is an object where template authors can pull out information from template actions and return them in a known standard way.
*/
@@ -73,6 +67,20 @@ export interface TemplateEntityV1beta3 extends Entity {
};
}
/**
* TODO
*/
export interface TemplateEntityStepV1beta3 extends JsonObject {
id?: string;
name?: string;
action: string;
input?: JsonObject;
if?: string | boolean;
metadata: {
tags?: string[];
};
}
const validator = entityKindSchemaValidator(schema);
/**
+4 -1
View File
@@ -26,4 +26,7 @@ export {
isTemplateEntityV1beta3,
} from './TemplateEntityV1beta3';
export * from './permissions';
export type { TemplateEntityV1beta3 } from './TemplateEntityV1beta3';
export type {
TemplateEntityV1beta3,
TemplateEntityStepV1beta3,
} from './TemplateEntityV1beta3';
+34 -6
View File
@@ -16,14 +16,42 @@
import { createPermission } from '@backstage/plugin-permission-common';
export const RESOURCE_TYPE_SCAFFOLDER_TEMPLATE = 'scaffolder-field';
export const RESOURCE_TYPE_SCAFFOLDER_PARAMETER = 'scaffolder-parameter';
export const RESOURCE_TYPE_SCAFFOLDER_PROPERTY = 'scaffolder-property';
export const RESOURCE_TYPE_SCAFFOLDER_STEP = 'scaffolder-step';
export const templateSchemaExecutePermission = createPermission({
name: 'scaffolder.template.schema.execute',
export const templateParameterReadPermission = createPermission({
name: 'scaffolder.template.parameter.read',
attributes: {
action: 'create',
action: 'read',
},
resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
resourceType: RESOURCE_TYPE_SCAFFOLDER_PARAMETER,
});
export const scaffolderPermissions = [templateSchemaExecutePermission];
export const templatePropertyReadPermission = createPermission({
name: 'scaffolder.template.property.read',
attributes: {
action: 'read',
},
resourceType: RESOURCE_TYPE_SCAFFOLDER_PROPERTY,
});
export const templateStepReadPermission = createPermission({
name: 'scaffolder.template.step.read',
attributes: {
action: 'read',
},
resourceType: RESOURCE_TYPE_SCAFFOLDER_STEP,
});
export const scaffolderParameterPermissions = [templateParameterReadPermission];
export const scaffolderPropertyPermissions = [templatePropertyReadPermission];
export const scaffolderStepPermissions = [templateStepReadPermission];
/**
* TODOs:
* 1. Implement for Parameters & Properties
* 2. What metadata should be included in the template?
* 3. Write tests
* 4. Write documentation
*/