chore: updated with review comments

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-02-24 14:14:58 +01:00
parent 4031764fca
commit 91c6faeb7b
9 changed files with 50 additions and 27 deletions
+5
View File
@@ -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`.
+1
View File
@@ -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.
@@ -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',
},
@@ -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';
+12 -12
View File
@@ -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<string, string>;
// (undocumented)
templateName: string;
templateRef: string;
// (undocumented)
values: Record<string, any>;
}
@@ -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;
@@ -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;
};
@@ -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;
};
+15 -1
View File
@@ -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,
+2 -2
View File
@@ -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;