feat: adding the option to pass secrets from the frontend from the ScaffolderApiClient

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-01-19 16:43:12 +01:00
parent 835b2da52a
commit 8100abfde2
+11 -2
View File
@@ -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<string, any>): Promise<string>;
scaffold(
templateName: string,
values: Record<string, any>,
secrets?: JsonObject,
): Promise<string>;
getTask(taskId: string): Promise<ScaffolderTask>;
@@ -155,6 +159,7 @@ export class ScaffolderClient implements ScaffolderApi {
async scaffold(
templateName: string,
values: Record<string, any>,
secrets: JsonObject = {},
): Promise<string> {
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) {