Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/imageAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as vscode from 'vscode';
import { globalConfig } from './config';
import { imageAnalysisService } from './exhortServices';
import { StatusMessages, Titles } from './constants';
import * as templates from './template';
import { Options } from '@trustification/exhort-javascript-api';
import { updateCurrentWebviewPanel } from './rhda';
import { buildLogErrorMessage } from './utils';
Expand Down Expand Up @@ -162,6 +163,15 @@ class DockerImageAnalysis {
try {
this.outputChannel.info(`generating image analysis report for "${this.filePath}"`);

// Check if no images were found
if (this.images.length === 0) {
this.outputChannel.info(`no images found in "${this.filePath}"`);
updateCurrentWebviewPanel(templates.NO_IMAGES_TEMPLATE);
p.report({ message: StatusMessages.WIN_FAILURE_DEPENDENCY_ANALYSIS });
this.imageAnalysisReportHtml = templates.NO_IMAGES_TEMPLATE;
return;
}

const options: IOptions = {
'RHDA_TOKEN': globalConfig.telemetryId ?? '',
'RHDA_SOURCE': globalConfig.utmSource,
Expand Down
4 changes: 4 additions & 0 deletions src/imageAnalysis/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ async function performDiagnostics(diagnosticFilePath: Uri, contents: string, pro
};

const images = provider.collect(contents);
if (images.length === 0) {
outputChannelDep.warn(`no image references found in ${diagnosticFilePath}`);
return;
}
const imageMap = new ImageMap(images, options);

const diagnosticsPipeline = new DiagnosticsPipeline(imageMap, diagnosticFilePath);
Expand Down
47 changes: 47 additions & 0 deletions src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,50 @@ export const ERROR_TEMPLATE = `<!DOCTYPE html>
</div>
</body>
</html>`;

export const NO_IMAGES_TEMPLATE = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html,body {
width: 99%;
height: 99%;
font-size: 16px;
font-family: system-ui, -apple-system, sans-serif;
}

body {
background: #ffffff;
display: flex;
align-items: center;
justify-content: center;
margin: 0;
padding: 20px;
}

.message-container {
text-align: center;
max-width: 500px;
}

h2 {
color: #333;
margin-bottom: 16px;
}

p {
color: #666;
line-height: 1.5;
}
</style>
</head>
<body>
<div class="message-container">
<h2>No Container Images Found</h2>
<p>This Dockerfile or Containerfile does not contain any image references to analyze.</p>
<p>Add <code>FROM</code> statements with base images to perform stack analysis.</p>
</div>
</body>
</html>`;