From 8100abfde283003bfe1c6a32e4a5c3d800ab24cd Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 19 Jan 2022 16:43:12 +0100 Subject: [PATCH] feat: adding the option to pass secrets from the frontend from the ScaffolderApiClient Signed-off-by: blam --- plugins/scaffolder/src/api.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder/src/api.ts b/plugins/scaffolder/src/api.ts index 70ed803ef7..767d3ac736 100644 --- a/plugins/scaffolder/src/api.ts +++ b/plugins/scaffolder/src/api.ts @@ -70,7 +70,11 @@ export interface ScaffolderApi { * @param templateName - Name of the Template entity for the scaffolder to use. New project is going to be created out of this template. * @param values - Parameters for the template, e.g. name, description */ - scaffold(templateName: string, values: Record): Promise; + scaffold( + templateName: string, + values: Record, + secrets?: JsonObject, + ): Promise; getTask(taskId: string): Promise; @@ -155,6 +159,7 @@ export class ScaffolderClient implements ScaffolderApi { async scaffold( templateName: string, values: Record, + secrets: JsonObject = {}, ): Promise { const { token } = await this.identityApi.getCredentials(); const url = `${await this.discoveryApi.getBaseUrl('scaffolder')}/v2/tasks`; @@ -164,7 +169,11 @@ export class ScaffolderClient implements ScaffolderApi { 'Content-Type': 'application/json', ...(token && { Authorization: `Bearer ${token}` }), }, - body: JSON.stringify({ templateName, values: { ...values } }), + body: JSON.stringify({ + templateName, + values: { ...values }, + secrets: secrets, + }), }); if (response.status !== 201) {