Provide information about the user into scaffolder template action's context

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2022-09-08 08:52:04 +02:00
parent 435a37bfa5
commit 6253418cb3
3 changed files with 18 additions and 2 deletions
@@ -27,7 +27,7 @@ import { ConflictError, InputError, NotFoundError } from '@backstage/errors';
import { Logger } from 'winston';
import { TokenIssuer, TokenParams } from '../../identity/types';
import { AuthResolverContext } from '../../providers';
import { AuthResolverCatalogUserQuery } from '../../providers/types';
import { AuthResolverCatalogUserQuery } from '../../providers';
import { CatalogIdentityClient } from '../catalog';
/**
@@ -18,8 +18,9 @@ import { Logger } from 'winston';
import { Writable } from 'stream';
import { JsonValue, JsonObject } from '@backstage/types';
import { Schema } from 'jsonschema';
import { TaskSecrets } from '../tasks/types';
import { TaskSecrets } from '../tasks';
import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
import { UserEntity } from '@backstage/catalog-model';
/**
* ActionContext is passed into scaffolder actions.
@@ -45,6 +46,20 @@ export type ActionContext<Input extends JsonObject> = {
* This will only ever be true if the actions as marked as supporting dry-runs.
*/
isDryRun?: boolean;
/**
* The user which triggered the action.
*/
user?: {
/**
* The decorated entity from the Catalog
*/
entity?: UserEntity;
/**
* An entity ref for the author of the task
*/
ref?: string;
};
};
/** @public */
@@ -300,6 +300,7 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
stepOutput[name] = value;
},
templateInfo: task.spec.templateInfo,
user: task.spec.user,
});
// Remove all temporary directories that were created when executing the action