From 9bf19466683b5c0498570476339523a38ceba853 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 10 Oct 2022 09:11:15 +0200 Subject: [PATCH] Updated the documentation Signed-off-by: bnechyporenko --- .changeset/sixty-llamas-itch.md | 14 ----------- plugins/scaffolder/README.md | 42 ++++++++++++++++++++++++++++++++ plugins/scaffolder/src/plugin.ts | 15 ++---------- 3 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 .changeset/sixty-llamas-itch.md diff --git a/.changeset/sixty-llamas-itch.md b/.changeset/sixty-llamas-itch.md deleted file mode 100644 index 49e0bb3752..0000000000 --- a/.changeset/sixty-llamas-itch.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -'@backstage/plugin-scaffolder': patch ---- - -Make it possible to enable useLongPollingLogs in scaffolder plugin. - -For that you have to add to your app-config.yaml file this snippet: - -```yaml -scaffolder: - useLongPollingLogs: true -``` - -By default, the value is `false`. diff --git a/plugins/scaffolder/README.md b/plugins/scaffolder/README.md index b74c03ec34..8194976445 100644 --- a/plugins/scaffolder/README.md +++ b/plugins/scaffolder/README.md @@ -79,6 +79,48 @@ export const Root = ({ children }: PropsWithChildren<{}>) => ( ``` +### Troubleshooting + +In case if you encountered with the [issue of closing EventStream](https://github.com/backstage/backstage/issues/5535) +which auto-updates logs during the task execution, you can enable long polling. In order to you it, you have to create +in your codebase file in this location `packages/app/src/apis.ts` where you register `ScaffolderClient` with an extra +parameter `useLongPollingLogs: true`. By default, it is `false`. + +```typescript +import { + createApiFactory, + discoveryApiRef, + fetchApiRef, + identityApiRef, +} from '@backstage/core-plugin-api'; + +import { + scaffolderApiRef, + ScaffolderClient, +} from '@backstage/plugin-scaffolder'; + +createApiFactory({ + api: scaffolderApiRef, + deps: { + discoveryApi: discoveryApiRef, + identityApi: identityApiRef, + scmIntegrationsApi: scmIntegrationsApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ scmIntegrationsApi, discoveryApi, identityApi, fetchApi }) => + new ScaffolderClient({ + discoveryApi, + identityApi, + scmIntegrationsApi, + fetchApi, + useLongPollingLogs: true, + }), +}); +``` + +Api factory creates the API and adds it to a registry. Because this file is processed before the default scaffolder +api registry, it is added to the registry prior and overrides the default behavior. + ## Links - [scaffolder-backend](https://github.com/backstage/backstage/tree/master/plugins/scaffolder-backend) diff --git a/plugins/scaffolder/src/plugin.ts b/plugins/scaffolder/src/plugin.ts index f64525ac8e..f9b359d93a 100644 --- a/plugins/scaffolder/src/plugin.ts +++ b/plugins/scaffolder/src/plugin.ts @@ -20,7 +20,7 @@ import { EntityPicker } from './components/fields/EntityPicker/EntityPicker'; import { entityNamePickerValidation } from './components/fields/EntityNamePicker'; import { EntityNamePicker } from './components/fields/EntityNamePicker/EntityNamePicker'; import { OwnerPicker } from './components/fields/OwnerPicker/OwnerPicker'; -import { repoPickerValidation } from './components'; +import { repoPickerValidation } from './components/fields/RepoUrlPicker'; import { RepoUrlPicker } from './components/fields/RepoUrlPicker/RepoUrlPicker'; import { createScaffolderFieldExtension } from './extensions'; import { @@ -30,7 +30,6 @@ import { viewTechDocRouteRef, } from './routes'; import { - configApiRef, createApiFactory, createPlugin, createRoutableExtension, @@ -51,27 +50,17 @@ export const scaffolderPlugin = createPlugin({ createApiFactory({ api: scaffolderApiRef, deps: { - configApi: configApiRef, discoveryApi: discoveryApiRef, scmIntegrationsApi: scmIntegrationsApiRef, fetchApi: fetchApiRef, identityApi: identityApiRef, }, - factory: ({ - configApi, - discoveryApi, - scmIntegrationsApi, - fetchApi, - identityApi, - }) => + factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) => new ScaffolderClient({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi, - useLongPollingLogs: - configApi.getOptionalBoolean('scaffolder.useLongPollingLogs') ?? - false, }), }), ],