UNPKG

snyk-docker-plugin

Version:
42 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getArchivePath = exports.getImageType = void 0; const path_1 = require("path"); const types_1 = require("./types"); function getImageType(targetImage) { const imageIdentifier = targetImage.split(":")[0]; switch (imageIdentifier) { case "docker-archive": return types_1.ImageType.DockerArchive; case "oci-archive": return types_1.ImageType.OciArchive; case "kaniko-archive": return types_1.ImageType.KanikoArchive; default: if (imageIdentifier.endsWith(".tar")) { return types_1.ImageType.UnspecifiedArchiveType; } else { return types_1.ImageType.Identifier; } } } exports.getImageType = getImageType; function getArchivePath(targetImage) { const possibleArchiveTypes = [ "docker-archive", "oci-archive", "kaniko-archive", ]; for (const archiveType of possibleArchiveTypes) { if (targetImage.startsWith(archiveType)) { return (0, path_1.normalize)(targetImage.substring(`${archiveType}:`.length)); } } if (targetImage.endsWith(".tar")) { return (0, path_1.normalize)(targetImage); } throw new Error('The provided archive path is missing a prefix, for example "docker-archive:", "oci-archive:" or "kaniko-archive"'); } exports.getArchivePath = getArchivePath; //# sourceMappingURL=image-type.js.map