"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1260.0/src/lib/container/index.ts" (4 Dec 2023, 1455 Bytes) of package /linux/misc/snyk-cli-1.1260.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import { ScannedProject } from '@snyk/cli-interface/legacy/common';
    2 import { MonitorMeta } from '../types';
    3 import { config as userConfig } from '../user-config';
    4 
    5 export const IMAGE_SAVE_PATH_OPT = 'imageSavePath';
    6 export const IMAGE_SAVE_PATH_ENV_VAR = 'SNYK_IMAGE_SAVE_PATH';
    7 
    8 export function isContainer(scannedProject: ScannedProject): boolean {
    9   return scannedProject.meta?.imageName?.length;
   10 }
   11 
   12 export function getContainerTargetFile(
   13   scannedProject: ScannedProject,
   14 ): string | undefined {
   15   return scannedProject.targetFile;
   16 }
   17 
   18 export function getContainerName(
   19   scannedProject: ScannedProject,
   20   meta: MonitorMeta,
   21 ): string | undefined {
   22   let name = scannedProject.meta?.imageName;
   23   if (meta['project-name']?.length) {
   24     name = meta['project-name'];
   25   }
   26   if (scannedProject.targetFile) {
   27     // for app+os projects the name of project is a mix of the image name
   28     // with the target file (if one exists)
   29     return name + ':' + scannedProject.targetFile;
   30   } else {
   31     return name;
   32   }
   33 }
   34 
   35 export function getContainerProjectName(
   36   scannedProject: ScannedProject,
   37   meta: MonitorMeta,
   38 ): string | undefined {
   39   let name = scannedProject.meta?.imageName;
   40   if (meta['project-name']?.length) {
   41     name = meta['project-name'];
   42   }
   43   return name;
   44 }
   45 
   46 export function getContainerImageSavePath(): string | undefined {
   47   return (
   48     process.env[IMAGE_SAVE_PATH_ENV_VAR] ||
   49     userConfig.get(IMAGE_SAVE_PATH_OPT) ||
   50     undefined
   51   );
   52 }