diff --git a/.changeset/fair-carrots-provide.md b/.changeset/fair-carrots-provide.md new file mode 100644 index 0000000000..01bc9e18bf --- /dev/null +++ b/.changeset/fair-carrots-provide.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +- **BREAKING** - the `/v2/tasks` endpoint now takes `templateRef` instead of `templateName` in the POST body. This should be a valid stringified `entityRef`. diff --git a/.changeset/slimy-drinks-tell.md b/.changeset/slimy-drinks-tell.md index f83953ccf6..87b9644d29 100644 --- a/.changeset/slimy-drinks-tell.md +++ b/.changeset/slimy-drinks-tell.md @@ -4,4 +4,5 @@ - **BREAKING** - `scaffolderApi.scaffold()` now takes one `options` argument instead of 3, the existing arguments should just be wrapped up in one object instead. - **BREAKING** - `scaffolderApi.scaffold()` now returns an object instead of a single string for the job ID. It's now `{ taskId: string }` +- **BREAKING** - `scaffolderApi.scaffold()` now takes a `templateRef` instead of `templateName` as an argument in the options. This should be a valid stringified `entityRef`. - **BREAKING** - `scaffolderApi.getIntegrationsList` now returns an object `{ integrations: { type: string, title: string, host: string }[] }` instead of just an array. diff --git a/plugins/scaffolder-backend/src/service/router.test.ts b/plugins/scaffolder-backend/src/service/router.test.ts index 6a66d6df47..fa1b649231 100644 --- a/plugins/scaffolder-backend/src/service/router.test.ts +++ b/plugins/scaffolder-backend/src/service/router.test.ts @@ -49,6 +49,7 @@ import request from 'supertest'; */ import { createRouter, DatabaseTaskStore, TaskBroker } from '../index'; import { StorageTaskBroker } from '../scaffolder/tasks/StorageTaskBroker'; +import { stringifyEntityRef } from '@backstage/catalog-model'; const createCatalogClient = (template: any) => ({ @@ -146,7 +147,10 @@ describe('createRouter', () => { const response = await request(app) .post('/v2/tasks') .send({ - templateName: 'create-react-app-template', + templateRef: stringifyEntityRef({ + kind: 'template', + name: 'create-react-app-template', + }), values: { storePath: 'https://github.com/backstage/backstage', }, @@ -165,7 +169,10 @@ describe('createRouter', () => { const response = await request(app) .post('/v2/tasks') .send({ - templateName: 'create-react-app-template', + templateRef: stringifyEntityRef({ + kind: 'template', + name: 'create-react-app-template', + }), values: { required: 'required-value', }, diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index eb7c0ebd78..84febe4225 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -20,11 +20,7 @@ import { UrlReader, } from '@backstage/backend-common'; import { CatalogApi } from '@backstage/catalog-client'; -import { - DEFAULT_NAMESPACE, - parseEntityRef, - stringifyEntityRef, -} from '@backstage/catalog-model'; +import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; import { InputError, NotFoundError } from '@backstage/errors'; diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index d8b433484d..df8f1ca9e2 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -146,23 +146,13 @@ export type LogEvent = { body: { message: string; stepId?: string; - status?: LogEventStatus; + status?: ScaffolderTaskStatus; }; createdAt: string; id: string; taskId: string; }; -// Warning: (ae-missing-release-tag) "LogEventStatus" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type LogEventStatus = - | 'open' - | 'processing' - | 'failed' - | 'completed' - | 'skipped'; - // Warning: (ae-missing-release-tag) "OwnedEntityPicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -365,7 +355,7 @@ export interface ScaffolderScaffoldOptions { // (undocumented) secrets?: Record; // (undocumented) - templateName: string; + templateRef: string; // (undocumented) values: Record; } @@ -410,6 +400,16 @@ export type ScaffolderTaskOutput = { [key: string]: unknown; }; +// Warning: (ae-missing-release-tag) "ScaffolderTaskStatus" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type ScaffolderTaskStatus = + | 'open' + | 'processing' + | 'failed' + | 'completed' + | 'skipped'; + // @public export const TaskPage: ({ loadingText }: TaskPageProps) => JSX.Element; diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx index 5387391e99..0882d49ff4 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx @@ -49,7 +49,7 @@ import React, { memo, useEffect, useMemo, useState } from 'react'; import { generatePath, useNavigate, useParams } from 'react-router'; import useInterval from 'react-use/lib/useInterval'; import { rootRouteRef } from '../../routes'; -import { LogEventStatus, ScaffolderTaskOutput } from '../../types'; +import { ScaffolderTaskStatus, ScaffolderTaskOutput } from '../../types'; import { useTaskEventStream } from '../hooks/useEventStream'; import { TaskPageLinks } from './TaskPageLinks'; @@ -86,7 +86,7 @@ const useStyles = makeStyles((theme: Theme) => type TaskStep = { id: string; name: string; - status: LogEventStatus; + status: ScaffolderTaskStatus; startedAt?: string; endedAt?: string; }; diff --git a/plugins/scaffolder/src/components/hooks/useEventStream.ts b/plugins/scaffolder/src/components/hooks/useEventStream.ts index b5ce7241a1..8ff9a30d0b 100644 --- a/plugins/scaffolder/src/components/hooks/useEventStream.ts +++ b/plugins/scaffolder/src/components/hooks/useEventStream.ts @@ -18,7 +18,7 @@ import { useEffect } from 'react'; import { scaffolderApiRef } from '../../api'; import { ScaffolderTask, - LogEventStatus, + ScaffolderTaskStatus, ScaffolderTaskOutput, LogEvent, } from '../../types'; @@ -27,7 +27,7 @@ import { Subscription } from '@backstage/types'; type Step = { id: string; - status: LogEventStatus; + status: ScaffolderTaskStatus; endedAt?: string; startedAt?: string; }; @@ -46,7 +46,7 @@ type ReducerLogEntry = { createdAt: string; body: { stepId?: string; - status?: LogEventStatus; + status?: ScaffolderTaskStatus; message: string; output?: ScaffolderTaskOutput; }; diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index 17c48e55ac..90d5445c8c 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -21,7 +21,21 @@ */ export { scaffolderApiRef, ScaffolderClient } from './api'; -export * from './types'; +export type { + JobStatus, + ListActionsResponse, + LogEvent, + ScaffolderApi, + ScaffolderGetIntegrationsListOptions, + ScaffolderGetIntegrationsListResponse, + ScaffolderScaffoldOptions, + ScaffolderScaffoldResponse, + ScaffolderStreamLogsOptions, + ScaffolderTask, + ScaffolderTaskOutput, + ScaffolderTaskStatus, + TemplateParameterSchema, +} from './types'; export { createScaffolderFieldExtension, ScaffolderFieldExtensions, diff --git a/plugins/scaffolder/src/types.ts b/plugins/scaffolder/src/types.ts index 47829885da..5d89f10291 100644 --- a/plugins/scaffolder/src/types.ts +++ b/plugins/scaffolder/src/types.ts @@ -17,7 +17,7 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common'; import { JsonObject, Observable } from '@backstage/types'; import { JSONSchema7 } from 'json-schema'; -export type LogEventStatus = +export type ScaffolderTaskStatus = | 'open' | 'processing' | 'failed' @@ -73,7 +73,7 @@ export type LogEvent = { body: { message: string; stepId?: string; - status?: LogEventStatus; + status?: ScaffolderTaskStatus; }; createdAt: string; id: string;