Merge pull request #9576 from backstage/blam/deprecations/scaffolder-backend

deprecations: remove deprecated `ctx.token`
This commit is contained in:
Ben Lambert
2022-02-16 18:32:09 +01:00
committed by GitHub
9 changed files with 11 additions and 24 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend': minor
---
**BREAKING**: `ctx.token` is now `ctx.secrets.backstageToken` in Actions. Please update any of your Actions that might call out to Backstage API's with this token.
-2
View File
@@ -41,7 +41,6 @@ export type ActionContext<Input extends JsonObject> = {
baseUrl?: string;
logger: Logger_2;
logStream: Writable;
token?: string | undefined;
secrets?: TaskSecrets;
workspacePath: string;
input: Input;
@@ -553,7 +552,6 @@ export class TaskManager implements TaskContext {
// @public
export type TaskSecrets = Record<string, string> & {
token?: string;
backstageToken?: string;
};
@@ -28,12 +28,6 @@ export type ActionContext<Input extends JsonObject> = {
logger: Logger;
logStream: Writable;
/**
* User token forwarded from initial request, for use in subsequent api requests
* @deprecated use `secrets.backstageToken` instead
*/
token?: string | undefined;
secrets?: TaskSecrets;
workspacePath: string;
input: Input;
@@ -236,8 +236,6 @@ export class HandlebarsWorkflowRunner implements WorkflowRunner {
logger: taskLogger,
logStream: stream,
input,
// this token is deprecated, and will be removed in favour of secrets.backstageToken instead.
token: task.secrets?.token,
secrets: task.secrets ?? {},
workspacePath,
async createTemporaryDirectory() {
@@ -203,13 +203,15 @@ describe('DefaultWorkflowRunner', () => {
],
},
{
token: fakeToken,
backstageToken: fakeToken,
},
);
await runner.execute(task);
expect(fakeActionHandler.mock.calls[0][0].token).toEqual(fakeToken);
expect(fakeActionHandler.mock.calls[0][0].secrets).toEqual(
expect.objectContaining({ backstageToken: fakeToken }),
);
});
});
@@ -258,17 +258,9 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
const tmpDirs = new Array<string>();
const stepOutput: { [outputName: string]: JsonValue } = {};
if (!task.spec.metadata) {
console.warn(
'DEPRECATION NOTICE: metadata is undefined. metadata will be required in the future.',
);
}
await action.handler({
baseUrl: task.spec.baseUrl,
input,
// this token is deprecated, and will be removed in favour of secrets.backstageToken instead.
token: task.secrets?.token,
secrets: task.secrets ?? {},
logger: taskLogger,
logStream: streamLogger,
@@ -38,7 +38,7 @@ async function createStore(): Promise<DatabaseTaskStore> {
describe('StorageTaskBroker', () => {
let storage: DatabaseTaskStore;
const fakeSecrets = { token: 'secret' } as TaskSecrets;
const fakeSecrets = { backstageToken: 'secret' } as TaskSecrets;
beforeAll(async () => {
storage = await createStore();
@@ -90,8 +90,6 @@ export type SerializedTaskEvent = {
* @public
*/
export type TaskSecrets = Record<string, string> & {
/** @deprecated Use `backstageToken` instead */
token?: string;
backstageToken?: string;
};
@@ -182,7 +182,7 @@ describe('createRouter', () => {
spec: {} as any,
status: 'completed',
createdAt: '',
secrets: { token: 'secret' },
secrets: { backstageToken: 'secret' },
});
const response = await request(app).get(`/v2/tasks/a-random-id`);