Skip to content

Commit b4e9de6

Browse files
committed
feat: add support for remote-repo-url UNIFY-506
1 parent 1e6bc04 commit b4e9de6

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lib/response-builder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ async function buildResponse(
200200
facts: [depGraphFact, ...additionalFacts],
201201
target: {
202202
image: depGraph.rootPkg.name,
203+
...(options &&
204+
options["remote-repo-url"] && {
205+
remoteUrl: options["remote-repo-url"],
206+
}),
203207
},
204208
identity: {
205209
type: depGraph.pkgManager.name,

lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export interface AutoDetectedUserInstructions {
104104

105105
export interface ContainerTarget {
106106
image: string;
107+
/** Set the remote URL for a container image image. */
108+
remoteUrl?: string;
107109
}
108110

109111
/**
@@ -228,6 +230,8 @@ export interface PluginOptions {
228230
/** The default is "false". */
229231
"collect-application-files": boolean | string;
230232
"target-reference": string;
233+
234+
"remote-repo-url": string;
231235
}
232236

233237
export interface DepTreeDep {

test/system/plugin-option.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,18 @@ it("provides imageName fact with imageNameAndDigest and imageNameAndTag scan opt
6060
]),
6161
);
6262
});
63+
64+
it("remoteUrl is set in ContainerTarget when remote-repo-url scan option is provided", async () => {
65+
const fixturePath = getFixture(["/docker-archives", "alpine-arm64.tar"]);
66+
const imagePath = `docker-archive:${fixturePath}`;
67+
68+
const pluginResponse = await plugin.scan({
69+
path: imagePath,
70+
"remote-repo-url": "https://github.com/org/my-repo-test",
71+
});
72+
pluginResponse.scanResults.forEach((scanResult) => {
73+
expect(scanResult.target.remoteUrl).toEqual(
74+
"https://github.com/org/my-repo-test",
75+
);
76+
});
77+
});

0 commit comments

Comments
 (0)