Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Catalog): Include RHBAC in the catalogs #1650

Merged
merged 1 commit into from
Nov 21, 2024
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
4 changes: 3 additions & 1 deletion packages/catalog-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
".": "./dist",
"./index.json": "./dist/camel-catalog/index.json",
"./types": "./dist/types/index.ts",
"./catalog-index.d.ts": "./dist/types/catalog-index.d.ts",
"./package.json": "./package.json",
"./*.json": "./dist/camel-catalog/*.json"
},
"scripts": {
"build": "yarn clean && yarn build:default:catalog && yarn build:ts",
"build:mvn": "./mvnw clean package --no-transfer-progress",
"build:default:catalog": "yarn run build:mvn; java -jar ./target/catalog-generator-0.0.1-SNAPSHOT.jar -o ./dist/camel-catalog -n \"Default Kaoto catalog\"",
"build:catalog": "node ./scripts/build-catalogs.mjs",
"build:default:catalog": "yarn run build:mvn; yarn run build:catalog",
"build:ts": "node --loader ts-node/esm ./scripts/json-schema-to-typescript.mts",
"lint": "yarn eslint \"scripts/**/*.{mts,ts}\"",
"lint:fix": "yarn lint --fix",
Expand Down
72 changes: 72 additions & 0 deletions packages/catalog-generator/scripts/build-catalogs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env ts-node
// @ts-check

import { spawn } from 'node:child_process';
import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import { resolve } from 'path';
import { existsSync } from 'node:fs';

const require = createRequire(import.meta.url);

/**
* @type {Record<import('../dist/types').CatalogRuntime, string[]>}
**/
const CATALOGS = {
Main: ['4.8.1', '4.4.4', '4.4.0.redhat-00046'],
Quarkus: ['3.16.0', '3.8.3', '3.8.0.redhat-00014'],
SpringBoot: ['4.8.1', '4.4.4', '4.4.0.redhat-00039'],
};
const KAMELETS_VERSION = '4.8.1';
Comment on lines +15 to +20
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the versions that get in the catalog, if we want them to be even friendlier for people to update, we could read them from a .txt file instead.


const generateCatalogs = () => {
let camelCatalogPath = '';
try {
const camelCatalogIndexJsonPath = require.resolve('@kaoto/camel-catalog/catalog-index.d.ts');
camelCatalogPath = dirname(camelCatalogIndexJsonPath);
} catch (error) {
throw new Error(`Could not find '@kaoto/camel-catalog' \n\n ${error}`);
} finally {
if (camelCatalogPath) console.log(`Found '@kaoto/camel-catalog' in ${camelCatalogPath}`, '\n');
}

const binary = resolve(camelCatalogPath, '../../target/catalog-generator-0.0.1-SNAPSHOT.jar');
if (!existsSync(binary)) {
throw new Error(`Could not find the catalog-generator JAR at ${binary}`);
}

const destinationFolder = resolve(camelCatalogPath, '../../dist/camel-catalog');
const args = [
'-jar',
binary,
'-o',
destinationFolder,
'-n',
'Default Kaoto catalog',
'-k',
KAMELETS_VERSION,
...getVersionArguments(),
];

spawn('java', args, {
stdio: 'inherit',
});
};

const getVersionArguments = () => {
/** @type string[] */
const starter = [];

return Object.entries(CATALOGS).reduce((acc, [runtime, versions]) => {
const flag = runtime.slice(0, 1).toLowerCase();

versions.forEach((version) => {
acc.push(`-${flag}`);
acc.push(version);
});

return acc;
}, starter);
};

generateCatalogs();
Loading