Input to set detector information

This commit is contained in:
Henri Maurer
2024-07-03 09:57:16 +01:00
parent 1203a182b5
commit 97fd7ee78d
5 changed files with 40 additions and 5 deletions
+11
View File
@@ -52,6 +52,17 @@ inputs:
required: false required: false
default: '' default: ''
detector-name:
description: The name of the detector that generated the dependency snapshot
type: string
detector-version:
description: The version of the detector that generated the dependency snapshot
type: string
detector-url:
description: The URL to the detector that generated the dependency snapshot
type: string
runs: runs:
using: node20 using: node20
+11 -1
View File
@@ -251,6 +251,14 @@ function run() {
sha: core.getInput('snapshot-sha'), sha: core.getInput('snapshot-sha'),
ref: core.getInput('snapshot-ref'), ref: core.getInput('snapshot-ref'),
}; };
const detectorName = core.getInput('detector-name');
if (detectorName !== '') {
snapshotConfig.detector = {
name: detectorName,
url: core.getInput('detector-url', { required: true }),
version: core.getInput('detector-version', { required: true }),
};
}
snapshot = yield (0, snapshot_generator_1.generateSnapshot)(directory, mavenConfig, snapshotConfig); snapshot = yield (0, snapshot_generator_1.generateSnapshot)(directory, mavenConfig, snapshotConfig);
} }
catch (err) { catch (err) {
@@ -475,6 +483,7 @@ const packageData = __nccwpck_require__(2876);
const DEPGRAPH_MAVEN_PLUGIN_VERSION = '4.0.2'; const DEPGRAPH_MAVEN_PLUGIN_VERSION = '4.0.2';
function generateSnapshot(directory, mvnConfig, snapshotConfig) { function generateSnapshot(directory, mvnConfig, snapshotConfig) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
var _a;
const depgraph = yield generateDependencyGraph(directory, mvnConfig); const depgraph = yield generateDependencyGraph(directory, mvnConfig);
try { try {
const mavenDependencies = new depgraph_1.MavenDependencyGraph(depgraph); const mavenDependencies = new depgraph_1.MavenDependencyGraph(depgraph);
@@ -493,7 +502,8 @@ function generateSnapshot(directory, mvnConfig, snapshotConfig) {
else { else {
manifest = mavenDependencies.createManifest(); manifest = mavenDependencies.createManifest();
} }
const snapshot = new dependency_submission_toolkit_1.Snapshot(getDetector(), snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.context, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.job); const detector = (_a = snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.detector) !== null && _a !== void 0 ? _a : getDetector();
const snapshot = new dependency_submission_toolkit_1.Snapshot(detector, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.context, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.job);
snapshot.addManifest(manifest); snapshot.addManifest(manifest);
const specifiedRef = getNonEmtptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref); const specifiedRef = getNonEmtptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref);
if (specifiedRef) { if (specifiedRef) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+8
View File
@@ -18,6 +18,14 @@ async function run() {
sha: core.getInput('snapshot-sha'), sha: core.getInput('snapshot-sha'),
ref: core.getInput('snapshot-ref'), ref: core.getInput('snapshot-ref'),
} }
const detectorName = core.getInput('detector-name');
if (detectorName !== '') {
snapshotConfig.detector = {
name: detectorName,
url: core.getInput('detector-url', { required: true }),
version: core.getInput('detector-version', { required: true }),
};
}
snapshot = await generateSnapshot(directory, mavenConfig, snapshotConfig); snapshot = await generateSnapshot(directory, mavenConfig, snapshotConfig);
} catch (err: any) { } catch (err: any) {
+7 -1
View File
@@ -22,6 +22,11 @@ export type SnapshotConfig = {
job?: any; job?: any;
sha?: any; sha?: any;
ref?: any; ref?: any;
detector?: {
name: string;
url: string;
version: string;
};
}; };
export async function generateSnapshot(directory: string, mvnConfig?: MavenConfiguration, snapshotConfig?: SnapshotConfig) { export async function generateSnapshot(directory: string, mvnConfig?: MavenConfiguration, snapshotConfig?: SnapshotConfig) {
@@ -44,7 +49,8 @@ export async function generateSnapshot(directory: string, mvnConfig?: MavenConfi
manifest = mavenDependencies.createManifest(); manifest = mavenDependencies.createManifest();
} }
const snapshot = new Snapshot(getDetector(), snapshotConfig?.context, snapshotConfig?.job); const detector = snapshotConfig?.detector ?? getDetector();
const snapshot = new Snapshot(detector, snapshotConfig?.context, snapshotConfig?.job);
snapshot.addManifest(manifest); snapshot.addManifest(manifest);
const specifiedRef = getNonEmtptyValue(snapshotConfig?.ref); const specifiedRef = getNonEmtptyValue(snapshotConfig?.ref);