From 6c2995fa1b3d02fd92c1f9abc02dc8523117e8de Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Sun, 2 Oct 2022 16:11:26 +0200 Subject: [PATCH 1/5] Make it possible to enable useLongPollingLogs in scaffolder plugin Signed-off-by: bnechyporenko --- plugins/scaffolder/src/plugin.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder/src/plugin.ts b/plugins/scaffolder/src/plugin.ts index f9b359d93a..f64525ac8e 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/fields/RepoUrlPicker'; +import { repoPickerValidation } from './components'; import { RepoUrlPicker } from './components/fields/RepoUrlPicker/RepoUrlPicker'; import { createScaffolderFieldExtension } from './extensions'; import { @@ -30,6 +30,7 @@ import { viewTechDocRouteRef, } from './routes'; import { + configApiRef, createApiFactory, createPlugin, createRoutableExtension, @@ -50,17 +51,27 @@ export const scaffolderPlugin = createPlugin({ createApiFactory({ api: scaffolderApiRef, deps: { + configApi: configApiRef, discoveryApi: discoveryApiRef, scmIntegrationsApi: scmIntegrationsApiRef, fetchApi: fetchApiRef, identityApi: identityApiRef, }, - factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) => + factory: ({ + configApi, + discoveryApi, + scmIntegrationsApi, + fetchApi, + identityApi, + }) => new ScaffolderClient({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi, + useLongPollingLogs: + configApi.getOptionalBoolean('scaffolder.useLongPollingLogs') ?? + false, }), }), ], From c8077a9f4ef86d720e70952460845eef6636c16a Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Sun, 2 Oct 2022 16:17:49 +0200 Subject: [PATCH 2/5] Make it possible to enable useLongPollingLogs in scaffolder plugin Signed-off-by: bnechyporenko --- .changeset/sixty-llamas-itch.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .changeset/sixty-llamas-itch.md diff --git a/.changeset/sixty-llamas-itch.md b/.changeset/sixty-llamas-itch.md new file mode 100644 index 0000000000..6bb8e85163 --- /dev/null +++ b/.changeset/sixty-llamas-itch.md @@ -0,0 +1,14 @@ +--- +'@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 falsy. From 0950e2fb99f3d6493113e7d604b66347052b9935 Mon Sep 17 00:00:00 2001 From: Bogdan Nechyporenko Date: Sun, 2 Oct 2022 19:49:06 +0200 Subject: [PATCH 3/5] Update sixty-llamas-itch.md Updated the doc Signed-off-by: acierto --- .changeset/sixty-llamas-itch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/sixty-llamas-itch.md b/.changeset/sixty-llamas-itch.md index 6bb8e85163..49e0bb3752 100644 --- a/.changeset/sixty-llamas-itch.md +++ b/.changeset/sixty-llamas-itch.md @@ -11,4 +11,4 @@ scaffolder: useLongPollingLogs: true ``` -By default, the value is falsy. +By default, the value is `false`. From 9bf19466683b5c0498570476339523a38ceba853 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 10 Oct 2022 09:11:15 +0200 Subject: [PATCH 4/5] 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, }), }), ], From e10411cebc3ed25c788415c5441d8399918081c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 11 Oct 2022 10:15:11 +0100 Subject: [PATCH 5/5] tweak wording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/scaffolder/README.md | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/scaffolder/README.md b/plugins/scaffolder/README.md index 8194976445..83fa01e6e5 100644 --- a/plugins/scaffolder/README.md +++ b/plugins/scaffolder/README.md @@ -81,10 +81,10 @@ 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`. +If you encounter the [issue of closing EventStream](https://github.com/backstage/backstage/issues/5535) +which auto-updates logs during task execution, you can enable long polling. To do so, +update your `packages/app/src/apis.ts` file to register a `ScaffolderClient` with the +`useLongPollingLogs` set to `true`. By default, it is `false`. ```typescript import { @@ -93,33 +93,33 @@ import { 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, - }), -}); +export const apis: AnyApiFactory[] = [ + 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, + }), + }), + // ... other factories ``` -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. +This replaces the default implementation of the `scaffolderApiRef`. ## Links