Skip to content

Commit e1280ab

Browse files
committed
feat: update SysdigWMRegistryFetchComponent to use sysdigApiClient
1 parent f68aa5e commit e1280ab

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/components/SysdigVMRegistryFetchComponent/SysdigVMRegistryFetchComponent.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ import {
2929
// methods
3030
getChips,
3131
getTitleWithBacklink,
32-
33-
API_PROXY_BASE_PATH,
34-
API_VULN_REGISTRY,
3532
getBacklink
3633
} from '../../lib';
34+
import { sysdigApiRef } from '../../api';
3735

3836
type RegistryScan = {
3937
mainAssetName: string,
@@ -102,20 +100,19 @@ export const DenseTable = ({ registryScans, title }: DenseTableProps) => {
102100

103101
export const SysdigVMRegistryFetchComponent = () => {
104102
const { entity } = useEntity();
105-
const backendUrl = useApi(configApiRef).getString('backend.baseUrl');
103+
const sysdigApiClient = useApi(sysdigApiRef)
106104
let endpoint: string | undefined = useApi(configApiRef).getOptionalString("sysdig.endpoint");
107105
let backlink_config: string | undefined = useApi(configApiRef).getOptionalString("sysdig.backlink");
108106

109107
var backlink = getBacklink(endpoint, backlink_config, "vm-registry");
110108

111-
let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_REGISTRY;
112109
let filter = '?filter=';
113110
var name;
114111

115112
const annotations = entity.metadata.annotations;
116113
if (annotations) {
117114
if (SYSDIG_CUSTOM_FILTER_ANNOTATION in annotations) {
118-
uri += '?filter=' + annotations[SYSDIG_CUSTOM_FILTER_ANNOTATION]
115+
filter += annotations[SYSDIG_CUSTOM_FILTER_ANNOTATION]
119116
} else {
120117

121118
var filters = []
@@ -140,19 +137,11 @@ export const SysdigVMRegistryFetchComponent = () => {
140137
}
141138

142139
filter += filters.join(' and ');
143-
uri += filter;
144140
backlink += filter;
145141
}
146142

147143
const { value, loading, error } = useAsync(async (): Promise<RegistryScan[]> => {
148-
const requestOptions = {
149-
method: 'GET',
150-
};
151-
152-
153-
const response = await fetch(uri, requestOptions);
154-
const data = await response.json();
155-
console.log(data.data)
144+
const data = await sysdigApiClient.fetchVulnRegistry(filter)
156145
return data.data;
157146
}, []);
158147

@@ -166,4 +155,4 @@ export const SysdigVMRegistryFetchComponent = () => {
166155
} else {
167156
return <Alert severity="warning">Please, add annotations to the entity.</Alert>;
168157
}
169-
};
158+
};

0 commit comments

Comments
 (0)