Skip to content

Commit 7dd2984

Browse files
committed
feat: implement OCI image analysis natively instead of via java API adapter
1 parent 6f34d82 commit 7dd2984

File tree

6 files changed

+42
-35
lines changed

6 files changed

+42
-35
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"type": "node",
3838
"request": "attach",
3939
"name": "Attach to Server",
40-
"port": 6009,
40+
"port": 6010,
4141
"restart": true,
4242
"sourceMaps": true,
4343
"outFiles": [
Binary file not shown.

package-lock.json

Lines changed: 32 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@
395395
"webpack-cli": "^5.1.4"
396396
},
397397
"dependencies": {
398-
"@fabric8-analytics/fabric8-analytics-lsp-server": "^0.10.0",
398+
"@fabric8-analytics/fabric8-analytics-lsp-server": "^0.10.1",
399399
"@redhat-developer/vscode-redhat-telemetry": "^0.8.0",
400400
"@trustification/exhort-api-spec": "^1.0.13",
401-
"@trustification/exhort-javascript-api": "^0.1.1",
401+
"@trustification/exhort-javascript-api": "^0.2.1-ea.0",
402402
"fs": "^0.0.1-security",
403403
"path": "^0.12.7",
404404
"vscode-languageclient": "^8.1.0"

src/exhortServices.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as vscode from 'vscode';
44
import exhort from '@trustification/exhort-javascript-api';
5-
import { execSync } from 'child_process';
65

76
import { IImageRef, IOptions } from './imageAnalysis';
87

@@ -13,28 +12,12 @@ import { IImageRef, IOptions } from './imageAnalysis';
1312
* @returns A Promise resolving to the analysis response in HTML format.
1413
*/
1514
async function imageAnalysisService(images: IImageRef[], options: IOptions): Promise<any> {
16-
const jarPath = `${__dirname}/../javaApiAdapter/exhort-java-api-adapter-1.0-SNAPSHOT-jar-with-dependencies.jar`;
17-
const reportType = 'html';
18-
let parameters = '';
19-
let properties = '';
20-
21-
images.forEach(image => {
22-
if (image.platform) {
23-
parameters += ` ${image.image}^^${image.platform}`;
24-
} else {
25-
parameters += ` ${image.image}`;
26-
}
27-
});
28-
29-
for (const setting in options) {
30-
if (options[setting]) {
31-
properties += ` -D${setting}=${options[setting]}`;
15+
return await exhort.imageAnalysis(images.map(img => {
16+
if (img.platform) {
17+
return `${img.image}^^${img.platform}`;
3218
}
33-
}
34-
35-
return execSync(`java${properties} -jar ${jarPath} ${reportType}${parameters}`, {
36-
maxBuffer: 1000 * 1000 * 10, // 10 MB
37-
}).toString();
19+
return img.image;
20+
}), true, options);
3821
}
3922

4023
/**

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export function activate(context: vscode.ExtensionContext) {
9292
path.join('dist', 'server.js')
9393
);
9494
// The debug options for the server
95-
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
96-
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
95+
// --inspect=6010: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
96+
const debugOptions = { execArgv: ['--nolazy', '--inspect=6010'] };
9797

9898
// If the extension is launched in debug mode then the debug server options are used
9999
// Otherwise the run options are used

0 commit comments

Comments
 (0)