Skip to content

Commit 3b94979

Browse files
committed
feat: update SysdigWMRuntimeFetchComponent to use sysdigApiClient
1 parent e1280ab commit 3b94979

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/components/SysdigVMRuntimeFetchComponent/SysdigVMRuntimeFetchComponent.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ import {
3434
getChips,
3535
getDetails,
3636
getTitleWithBacklink,
37-
38-
API_PROXY_BASE_PATH,
39-
API_VULN_RUNTIME,
4037
getBacklink
4138
} from '../../lib'
39+
import { sysdigApiRef } from '../../api';
4240

4341

4442
type RuntimeScan = {
@@ -153,21 +151,21 @@ export const DenseTable = ({ runtimeScans, title }: DenseTableProps) => {
153151

154152
export const SysdigVMRuntimeFetchComponent = () => {
155153
const { entity } = useEntity();
156-
const backendUrl = useApi(configApiRef).getString('backend.baseUrl');
154+
const sysdigApiClient = useApi(sysdigApiRef)
157155
let endpoint: string | undefined = useApi(configApiRef).getOptionalString("sysdig.endpoint");
158156
let backlink_config: string | undefined = useApi(configApiRef).getOptionalString("sysdig.backlink");
159157

160158
var backlink = getBacklink(endpoint, backlink_config, "vm-runtime");
161159

162-
let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_RUNTIME;
160+
163161
let filter = '?filter=';
164162
var names;
165163

166164
const annotations = entity.metadata.annotations;
167165
if (annotations) {
168166

169167
if (SYSDIG_CUSTOM_FILTER_ANNOTATION in annotations) {
170-
uri += '?filter=' + annotations[SYSDIG_CUSTOM_FILTER_ANNOTATION]
168+
filter += annotations[SYSDIG_CUSTOM_FILTER_ANNOTATION]
171169
} else {
172170

173171
var filters = []
@@ -202,17 +200,11 @@ export const SysdigVMRuntimeFetchComponent = () => {
202200
}
203201

204202
filter += filters.join(' and ');
205-
uri += filter;
206203
backlink += filter;
207204
}
208205

209206
const { value, loading, error } = useAsync(async (): Promise<RuntimeScan[]> => {
210-
const requestOptions = {
211-
method: 'GET',
212-
};
213-
214-
const response = await fetch(uri, requestOptions);
215-
const data = await response.json();
207+
const data = await sysdigApiClient.fetchVulnRuntime(filter)
216208
return data.data;
217209
}, []);
218210

0 commit comments

Comments
 (0)