chore: updating to use templateRef

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-02-24 14:01:51 +01:00
parent f46c712a96
commit 4031764fca
4 changed files with 18 additions and 9 deletions
+5 -3
View File
@@ -90,7 +90,9 @@ export class ScaffolderClient implements ScaffolderApi {
async getTemplateParameterSchema(
templateRef: string,
): Promise<TemplateParameterSchema> {
const { namespace, kind, name } = parseEntityRef(templateRef);
const { namespace, kind, name } = parseEntityRef(templateRef, {
defaultKind: 'template',
});
const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');
const templatePath = [namespace, kind, name]
@@ -117,7 +119,7 @@ export class ScaffolderClient implements ScaffolderApi {
async scaffold(
options: ScaffolderScaffoldOptions,
): Promise<ScaffolderScaffoldResponse> {
const { templateName, values, secrets = {} } = options;
const { templateRef, values, secrets = {} } = options;
const url = `${await this.discoveryApi.getBaseUrl('scaffolder')}/v2/tasks`;
const response = await this.fetchApi.fetch(url, {
method: 'POST',
@@ -125,7 +127,7 @@ export class ScaffolderClient implements ScaffolderApi {
'Content-Type': 'application/json',
},
body: JSON.stringify({
templateName,
templateRef,
values: { ...values },
secrets,
}),
@@ -41,6 +41,7 @@ import {
useApiHolder,
useRouteRef,
} from '@backstage/core-plugin-api';
import { stringifyEntityRef } from '@backstage/catalog-model';
const useTemplateParameterSchema = (templateRef: string) => {
const scaffolderApi = useApi(scaffolderApiRef);
@@ -137,7 +138,11 @@ export const TemplatePage = ({
const handleCreate = async () => {
const { taskId } = await scaffolderApi.scaffold({
templateName,
templateRef: stringifyEntityRef({
name: templateName,
kind: 'template',
namespace: 'default',
}),
values: formState,
secrets: secretsContext?.secrets,
});
+1 -1
View File
@@ -81,7 +81,7 @@ export type LogEvent = {
};
export interface ScaffolderScaffoldOptions {
templateName: string;
templateRef: string;
values: Record<string, any>;
secrets?: Record<string, string>;
}