Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2024 The Nephio Authors.
# Copyright (c) 2024 The kpt Authors
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 18
node-version: 26
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint
Expand All @@ -58,7 +58,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 18
node-version: 26
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
Expand Down
4 changes: 2 additions & 2 deletions .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ presubmits:
always_run: true
spec:
containers:
- image: nephio/gotests:1783899289886396416
- image: kpt/gotests:1783899289886396416
command:
- "/bin/sh"
- "-c"
Expand All @@ -50,7 +50,7 @@ presubmits:
always_run: true
spec:
containers:
- image: nephio/scancode-toolkit:v31.2.5
- image: kpt/scancode-toolkit:v31.2.5
command:
- "/bin/sh"
args:
Expand Down
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# Kpt Backstage Plugins

**NOTICE** This is a fork of the upstream Kpt Backstage Plugin repository. The
intention is to upstream relevant changes to that repository after kpt moves to
CNCF and has the CNCF CLA. Please keep changes that are Nephio-specific (i.e.,
do not belong in the upstream project) easily separable (or do them in a
different repository).

Welcome! This repository contains the Kpt Backstage Plugins. The plugins can be
installed into an existing Backstage Application following the READMEs for each
plugin. For development and testing, the plugins can also be executed with the
example Backstage Application in this repository.

[Configuration as Data](plugins/cad) is the primary plugin which powers the
WYSIWYG Configuration GUI over GitOps using [kpt](https://kpt.dev/) and its new
Package Orchestrator,
[Porch](https://github.com/GoogleContainerTools/kpt/tree/main/porch).
WYSIWYG Configuration GUI over GitOps using [kpt](https://kpt.dev/) and its
Package Orchestrator, [Porch](https://github.com/kptdev//porch).

![CaD Landing Page](images/cad-plugin-landing.png)

Expand Down Expand Up @@ -68,9 +61,9 @@ yarn install
### Running the UI

To run the UI, you'll need to use this command will start Backstage frontend and
backend instances. The frontend instance is hosted on port 3000 and, the backend
backend instances. The frontend instance is hosted on port 3900 and, the backend
instance is on port 7007. Once started, you'll be able to access the UI by
browsing to the URL http://localhost:3000.
browsing to the URL http://localhost:3900.

```bash
yarn dev
Expand Down
4 changes: 2 additions & 2 deletions app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

app:
title: Kpt Backstage Plugins
baseUrl: http://localhost:3000
baseUrl: http://localhost:3900

organization:
name: Kpt Backstage Plugins
Expand All @@ -31,7 +31,7 @@ backend:
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
# Default Helmet Content-Security-Policy values can be removed by setting the key to false
cors:
origin: http://localhost:3000
origin: http://localhost:3900
methods: [GET, POST, PUT, DELETE]
credentials: true
database:
Expand Down
2 changes: 1 addition & 1 deletion hack/resources/package-repositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
git:
branch: main
directory: /
repo: https://github.com/GoogleContainerTools/kpt-samples.git
repo: https://github.com/kptdev/kpt-samples.git
type: git
---
apiVersion: config.porch.kpt.dev/v1alpha1
Expand Down
9 changes: 9 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// Polyfill for SlowBuffer removed in Node.js 26
const buffer = require('buffer');
if (!buffer.SlowBuffer) {
buffer.SlowBuffer = function SlowBuffer(length) {
return Buffer.allocUnsafe(length);
};
buffer.SlowBuffer.prototype = Buffer.prototype;
}

const { TextEncoder, TextDecoder } = require('util');

global.TextEncoder = TextEncoder;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
},
"dependencies": {
"@types/react": "^17",
"@types/react-dom": "^17"
"@types/react-dom": "^17",
"better-sqlite3": "^12.10.0"
}
}
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"history": "^5.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"react-use": "^15.3.3"
},
"devDependencies": {
Expand Down
Binary file removed packages/app/public/nephio-background.png
Binary file not shown.
15 changes: 0 additions & 15 deletions packages/app/public/nephio_logo_colorwhite_horizontal.svg

This file was deleted.

21 changes: 4 additions & 17 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,24 @@
"role": "backend"
},
"scripts": {
"start": "backstage-cli package start",
"start": "NODE_OPTIONS='--require ./polyfill.js' backstage-cli package start",
"build": "backstage-cli package build",
"lint": "backstage-cli package lint",
"test": "backstage-cli package test",
"clean": "backstage-cli package clean"
},
"dependencies": {
"@backstage/backend-common": "^0.22.0",
"@backstage/backend-tasks": "^0.5.23",
"@backstage/backend-defaults": "^0.2.18",
"@backstage/config": "^1.2.0",
"@backstage/plugin-app-backend": "^0.3.67",
"@backstage/plugin-auth-backend": "^0.22.5",
"@backstage/plugin-catalog-backend": "^1.22.0",
"@backstage/plugin-permission-common": "^0.7.13",
"@backstage/plugin-permission-node": "^0.7.29",
"@backstage/plugin-proxy-backend": "^0.4.16",
"@kpt/backstage-plugin-cad-backend": "*",
"app": "link:../app",
"better-sqlite3": "^11.8.0",
"dockerode": "^3.3.1",
"express": "^4.17.1",
"express-promise-router": "^4.1.0",
"luxon": "^2.0.2",
"winston": "^3.2.1"
"better-sqlite3": "^12.10.0"
},
"devDependencies": {
"@backstage/cli": "^0.26.6",
"@types/dockerode": "^3.3.0",
"@types/express": "^4.17.6",
"@types/express-serve-static-core": "^4.17.5",
"@types/luxon": "^2.0.4"
"@backstage/cli": "^0.26.6"
},
"files": [
"dist"
Expand Down
12 changes: 12 additions & 0 deletions packages/backend/polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Polyfill for SlowBuffer which was removed in Node.js 26.
* Required by buffer-equal-constant-time (transitive dep of jsonwebtoken).
*/
const buffer = require('buffer');

if (!buffer.SlowBuffer) {
buffer.SlowBuffer = function SlowBuffer(length) {
return Buffer.allocUnsafe(length);
};
buffer.SlowBuffer.prototype = Buffer.prototype;
}
24 changes: 0 additions & 24 deletions packages/backend/src/index.test.ts

This file was deleted.

102 changes: 9 additions & 93 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2024 The kpt Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,98 +14,14 @@
* limitations under the License.
*/

import {
CacheManager,
createServiceBuilder,
DatabaseManager,
getRootLogger,
loadBackendConfig,
notFoundHandler,
ServerTokenManager,
SingleHostDiscovery,
UrlReaders,
useHotMemoize,
} from '@backstage/backend-common';
import { TaskScheduler } from '@backstage/backend-tasks';
import { Config } from '@backstage/config';
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
import Router from 'express-promise-router';
import app from './plugins/app';
import auth from './plugins/auth';
import cad from './plugins/cad';
import catalog from './plugins/catalog';
import proxy from './plugins/proxy';
import { PluginEnvironment } from './types';
import { createBackend } from '@backstage/backend-defaults';

function makeCreateEnv(config: Config) {
const root = getRootLogger();
const reader = UrlReaders.default({ logger: root, config });
const discovery = SingleHostDiscovery.fromConfig(config);
const cacheManager = CacheManager.fromConfig(config);
const databaseManager = DatabaseManager.fromConfig(config);
const tokenManager = ServerTokenManager.noop();
const taskScheduler = TaskScheduler.fromConfig(config);
const permissions = ServerPermissionClient.fromConfig(config, {
discovery,
tokenManager,
});
const backend = createBackend();

root.info(`Created UrlReader ${reader}`);
backend.add(import('@backstage/plugin-app-backend/alpha'));
backend.add(import('@backstage/plugin-auth-backend'));
backend.add(import('@backstage/plugin-catalog-backend/alpha'));
backend.add(import('@backstage/plugin-proxy-backend/alpha'));
backend.add(import('@kpt/backstage-plugin-cad-backend'));

return (plugin: string): PluginEnvironment => {
const logger = root.child({ type: 'plugin', plugin });
const database = databaseManager.forPlugin(plugin);
const cache = cacheManager.forPlugin(plugin);
const scheduler = taskScheduler.forPlugin(plugin);
return {
logger,
database,
cache,
config,
reader,
discovery,
tokenManager,
scheduler,
permissions,
};
};
}

async function main() {
const config = await loadBackendConfig({
argv: process.argv,
logger: getRootLogger(),
});
const createEnv = makeCreateEnv(config);

const cadEnv = useHotMemoize(module, () => createEnv('cad'));
const authEnv = useHotMemoize(module, () => createEnv('auth'));
const catalogEnv = useHotMemoize(module, () => createEnv('catalog'));
const proxyEnv = useHotMemoize(module, () => createEnv('proxy'));
const appEnv = useHotMemoize(module, () => createEnv('app'));

const apiRouter = Router();
apiRouter.use('/config-as-data', await cad(cadEnv));
apiRouter.use('/auth', await auth(authEnv));
apiRouter.use('/catalog', await catalog(catalogEnv));
apiRouter.use('/proxy', await proxy(proxyEnv));

// Add backends ABOVE this line; this 404 handler is the catch-all fallback
apiRouter.use(notFoundHandler());

const service = createServiceBuilder(module)
.loadConfig(config)
.addRouter('/api', apiRouter)
.addRouter('', await app(appEnv));

await service.start().catch(err => {
console.log(err);
process.exit(1);
});
}

module.hot?.accept();
main().catch(error => {
console.error(`Backend failed to start up, ${error}`);
process.exit(1);
});
backend.start();
28 changes: 0 additions & 28 deletions packages/backend/src/plugins/app.ts

This file was deleted.

Loading
Loading