feat: update related to #3066

This commit is contained in:
Marvin9
2020-10-27 10:53:40 +05:30
parent 8440f8f91b
commit f2a9bba5e2
@@ -38,13 +38,15 @@ export class CatalogEntityClient {
* Throws a NotFoundError or ConflictError if 0 or multiple templates are found.
*/
async findTemplate(templateName: string): Promise<TemplateEntityV1alpha1> {
const params = new URLSearchParams();
params.append('kind', 'Template');
params.append('metadata.name', templateName);
const conditions = [
'kind=template',
`metadata.name=${encodeURIComponent(templateName)}`,
];
const baseUrl = await this.discovery.getBaseUrl('catalog');
const response = await fetch(`${baseUrl}/entities?${params}`);
const response = await fetch(
`${baseUrl}/entities?filter=${conditions.join(',')}`,
);
if (!response.ok) {
const text = await response.text();