scaffolder,scaffolder-backend: fix tests, lint and type issues
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
committed by
Johan Haals
parent
6fa98f941b
commit
8b003875a8
@@ -154,7 +154,6 @@ export class TaskWorker {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('DEBUG: templateCtx =', JSON.stringify(templateCtx, 0, 2));
|
||||
const output = JSON.parse(
|
||||
JSON.stringify(task.spec.output),
|
||||
(_key, value) => {
|
||||
@@ -169,7 +168,6 @@ export class TaskWorker {
|
||||
return value;
|
||||
},
|
||||
);
|
||||
console.log('DEBUG: output =', output);
|
||||
|
||||
await task.complete('completed', { output });
|
||||
} catch (error) {
|
||||
|
||||
@@ -27,9 +27,7 @@ import {
|
||||
import { JsonValue } from '@backstage/config';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { getEntityName } from '@backstage/catalog-model';
|
||||
import { PublisherBuilder } from '../stages';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import { Config } from '@backstage/config';
|
||||
import { initRepoAndPush } from '../stages/publish/helpers';
|
||||
|
||||
async function fetchContents({
|
||||
@@ -53,6 +51,7 @@ async function fetchContents({
|
||||
|
||||
let fetchUrlIsAbsolute = false;
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new URL(fetchUrl);
|
||||
fetchUrlIsAbsolute = true;
|
||||
} catch {
|
||||
@@ -300,10 +299,8 @@ export function createPublishGithubAction(options: {
|
||||
});
|
||||
}
|
||||
|
||||
const remoteUrl = data?.clone_url;
|
||||
const repoContentsUrl = data?.html_url
|
||||
? `${data?.html_url}/blob/master`
|
||||
: undefined;
|
||||
const remoteUrl = data.clone_url;
|
||||
const repoContentsUrl = `${data?.html_url}/blob/master`;
|
||||
|
||||
await initRepoAndPush({
|
||||
dir: ctx.workspacePath,
|
||||
@@ -354,7 +351,6 @@ export function createCatalogRegisterAction(options: {
|
||||
type: 'url',
|
||||
target: catalogInfoUrl as string,
|
||||
});
|
||||
console.log('DEBUG: result.entities =', result.entities);
|
||||
if (result.entities.length >= 1) {
|
||||
const { kind, name, namespace } = getEntityName(result.entities[0]);
|
||||
ctx.output('entityRef', `${kind}:${namespace}/${name}`);
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
SingleConnectionDatabaseManager,
|
||||
PluginDatabaseManager,
|
||||
getVoidLogger,
|
||||
UrlReaders,
|
||||
} from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import express from 'express';
|
||||
@@ -61,6 +62,11 @@ function createDatabase(): PluginDatabaseManager {
|
||||
).forPlugin('scaffolder');
|
||||
}
|
||||
|
||||
const mockUrlReader = UrlReaders.default({
|
||||
logger: getVoidLogger(),
|
||||
config: new ConfigReader({}),
|
||||
});
|
||||
|
||||
describe('createRouter - working directory', () => {
|
||||
const mockPrepare = jest.fn();
|
||||
const mockPreparers = new Preparers();
|
||||
@@ -112,6 +118,7 @@ describe('createRouter - working directory', () => {
|
||||
dockerClient: new Docker(),
|
||||
database: createDatabase(),
|
||||
catalogClient: createCatalogClient([template]),
|
||||
urlReader: mockUrlReader,
|
||||
}),
|
||||
).rejects.toThrow('access error');
|
||||
});
|
||||
@@ -126,6 +133,7 @@ describe('createRouter - working directory', () => {
|
||||
dockerClient: new Docker(),
|
||||
database: createDatabase(),
|
||||
catalogClient: createCatalogClient([template]),
|
||||
urlReader: mockUrlReader,
|
||||
});
|
||||
|
||||
const app = express().use(router);
|
||||
@@ -155,6 +163,7 @@ describe('createRouter - working directory', () => {
|
||||
dockerClient: new Docker(),
|
||||
database: createDatabase(),
|
||||
catalogClient: createCatalogClient([template]),
|
||||
urlReader: mockUrlReader,
|
||||
});
|
||||
|
||||
const app = express().use(router);
|
||||
@@ -228,6 +237,7 @@ describe('createRouter', () => {
|
||||
dockerClient: new Docker(),
|
||||
database: createDatabase(),
|
||||
catalogClient: createCatalogClient([template]),
|
||||
urlReader: mockUrlReader,
|
||||
});
|
||||
app = express().use(router);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { discoveryApiRef, identityApiRef } from '@backstage/core';
|
||||
import { configApiRef, discoveryApiRef, identityApiRef } from '@backstage/core';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { ScaffolderPage } from '../src/plugin';
|
||||
@@ -30,9 +30,13 @@ createDevApp()
|
||||
})
|
||||
.registerApi({
|
||||
api: scaffolderApiRef,
|
||||
deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
|
||||
factory: ({ discoveryApi, identityApi }) =>
|
||||
new ScaffolderClient({ discoveryApi, identityApi }),
|
||||
deps: {
|
||||
discoveryApi: discoveryApiRef,
|
||||
identityApi: identityApiRef,
|
||||
configApi: configApiRef,
|
||||
},
|
||||
factory: ({ discoveryApi, identityApi, configApi }) =>
|
||||
new ScaffolderClient({ discoveryApi, identityApi, configApi }),
|
||||
})
|
||||
.addPage({
|
||||
path: '/create',
|
||||
|
||||
@@ -36,6 +36,7 @@ jest.mock('react-router-dom', () => {
|
||||
const scaffolderApiMock: jest.Mocked<ScaffolderApi> = {
|
||||
scaffold: jest.fn(),
|
||||
getTemplateParameterSchema: jest.fn(),
|
||||
getIntegrationsList: jest.fn(),
|
||||
getTask: jest.fn(),
|
||||
streamLogs: jest.fn(),
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React, { useState, useCallback, useEffect } from 'react';
|
||||
import React, { useCallback, useEffect } from 'react';
|
||||
import { Field } from '@rjsf/core';
|
||||
import { useApi, Progress } from '@backstage/core';
|
||||
import { scaffolderApiRef } from '../../../api';
|
||||
@@ -104,7 +104,7 @@ export const RepoUrlPicker: Field = ({
|
||||
if (host === undefined && integrations?.length) {
|
||||
onChange(serializeFormData({ host: integrations[0].host, owner, repo }));
|
||||
}
|
||||
}, [integrations, host]);
|
||||
}, [onChange, integrations, host, owner, repo]);
|
||||
|
||||
if (loading) {
|
||||
return <Progress />;
|
||||
@@ -121,9 +121,9 @@ export const RepoUrlPicker: Field = ({
|
||||
<Select native id="hostInput" onChange={updateHost} value={host}>
|
||||
{integrations!
|
||||
.filter(i => allowedHosts?.includes(i.host))
|
||||
.map(({ host, title }) => (
|
||||
<option key={host} value={host}>
|
||||
{title}
|
||||
.map(i => (
|
||||
<option key={i.host} value={i.host}>
|
||||
{i.title}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
Reference in New Issue
Block a user