Skip to content

Commit

Permalink
add policy report mock data for dev mode setup
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikjeeyar committed Jan 26, 2024
1 parent 2417a17 commit 4ac314c
Show file tree
Hide file tree
Showing 12 changed files with 669 additions and 83 deletions.
40 changes: 33 additions & 7 deletions plugins/tekton/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import {
import { TestApiProvider } from '@backstage/test-utils';

import { mockKubernetesPlrResponse } from '../src/__fixtures__/1-pipelinesData';
import {
acsDeploymentCheck,
acsImageCheckResults,
acsImageScanResult,
} from '../src/__fixtures__/advancedClusterSecurityData';
import { enterpriseContractResult } from '../src/__fixtures__/enterpriseContractData';
import { TektonCI, tektonPlugin } from '../src/plugin';

const mockEntity: Entity = {
Expand All @@ -35,13 +41,33 @@ const mockEntity: Entity = {

class MockKubernetesProxyApi implements KubernetesProxyApi {
async getPodLogs(_request: any): Promise<any> {
return new Promise(resolve => {
setTimeout(() => {
resolve({
text: `\nstreaming logs from container: ${_request.containerName} \n...`,
});
}, 500);
});
const delayedResponse = (data: string, ms: number) =>
new Promise(resolve => {
setTimeout(() => {
resolve({
text: data,
});
}, ms);
});

if (_request.podName.includes('ec-task')) {
return delayedResponse(JSON.stringify(enterpriseContractResult), 100);
}

if (_request.podName.includes('image-scan-task')) {
return delayedResponse(JSON.stringify(acsImageScanResult), 200);
}

if (_request.podName.includes('image-check-task')) {
return delayedResponse(JSON.stringify(acsImageCheckResults), 300);
}

if (_request.podName.includes('deployment-check-task')) {
return delayedResponse(JSON.stringify(acsDeploymentCheck), 400);
}

const response = `\nstreaming logs from container: ${_request.containerName} \n...`;
return delayedResponse(response, 500);
}

async getEventsByInvolvedObjectName(): Promise<any> {
Expand Down
Loading

0 comments on commit 4ac314c

Please sign in to comment.