Skip to content

Commit 6058deb

Browse files
authored
fix: use & pass down opts for getCustom in imageAnalysis (#244)
1 parent 60c5f9d commit 6058deb

File tree

10 files changed

+165
-124
lines changed

10 files changed

+165
-124
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
with:
5959
python-version: '3.9'
6060
cache: 'pip'
61+
6162
- name: get Python location
6263
id: python-location
6364
run: |

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757
"devDependencies": {
5858
"@babel/core": "^7.23.2",
59-
"@trustification/exhort-api-spec": "^1.0.13",
59+
"@trustification/exhort-api-spec": "^1.0.18",
6060
"@types/node": "^20.17.30",
6161
"@types/which": "^3.0.4",
6262
"babel-plugin-rewire": "^1.2.0",

src/analysis.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ async function requestComponent(provider, manifest, url, opts = {}) {
156156
async function requestImages(imageRefs, url, html = false, opts = {}) {
157157
const imageSboms = {}
158158
for (const image of imageRefs) {
159-
const parsedImageRef = parseImageRef(image)
160-
imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef)
159+
const parsedImageRef = parseImageRef(image, opts)
160+
imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef, opts)
161161
}
162162

163163
const finalUrl = new URL(`${url}/api/v4/batch-analysis`);

src/oci_image/images.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,32 +216,33 @@ export class ImageRef {
216216
/**
217217
* @param {string} image
218218
* @param {string} [platform]
219+
* @param {import("index.js").Options} [opts={}]
219220
*/
220-
constructor(image, platform) {
221+
constructor(image, platform, opts) {
221222
this.image = new Image(image);
222223

223224
if (platform != null) {
224225
this.platform = Platform.fromString(platform);
225226
}
226227

227-
this.checkImageDigest();
228+
this.checkImageDigest(opts);
228229
}
229230

230231
/**
231232
* @private
232233
*/
233-
checkImageDigest() {
234+
checkImageDigest(opts) {
234235
if (this.image.digest == null) {
235236
try {
236-
const digests = getImageDigests(this);
237+
const digests = getImageDigests(this, opts);
237238
if (digests.size === 0) {
238239
throw new Error("Failed to get any image digest");
239240
}
240241
if (digests.size === 1 && digests[Platform.EMPTY.toString()]) {
241242
this.image.digest = digests[Platform.EMPTY.toString()];
242243
} else {
243244
if (this.platform == null) {
244-
this.platform = getImagePlatform();
245+
this.platform = getImagePlatform(opts);
245246
}
246247
if (this.platform == null) {
247248
throw new Error(`Failed to get image platform for image digest`);

0 commit comments

Comments
 (0)