Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

fix(plugins-view): Register custom plugin registries from devfile plugins #1131

Merged
merged 5 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { PluginFilter } from '../../common/plugin/plugin-filter';
import { PluginServer } from '@theia/plugin-ext/lib/common/plugin-protocol';
import URI from '@theia/core/lib/common/uri';
import { WorkspaceService } from '@eclipse-che/theia-remote-api/lib/common/workspace-service';
import { DevfileService } from '@eclipse-che/theia-remote-api/lib/common/devfile-service';

import debounce = require('lodash.debounce');

Expand Down Expand Up @@ -79,6 +80,9 @@ export class ChePluginManager {
@inject(OpenerService)
protected readonly openerService: OpenerService;

@inject(DevfileService)
protected readonly devfileService: DevfileService;

@postConstruct()
async onStart() {
await this.initDefaults();
Expand Down Expand Up @@ -222,6 +226,17 @@ export class ChePluginManager {
registries[registry.name] = registry;
}

const devfile = await this.devfileService.get();
if (devfile.components) {
const components = devfile.components.filter(component => component.plugin && component.plugin.id && component.plugin.registryUrl);
for (let i = 0; i < components.length; i++) {
const component = components[i];
vinokurig marked this conversation as resolved.
Show resolved Hide resolved
const registryUrl = component.plugin?.registryUrl!;
const name = component.plugin?.id!
registries[name] = { name, uri: registryUrl, publicUri: registryUrl };
}
}

await this.chePluginService.updateCache(registries);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ChePluginServiceImpl implements ChePluginService {

for (let pIndex = 0; pIndex < registryPlugins.length; pIndex++) {
const metadataInternal: ChePluginMetadataInternal = registryPlugins[pIndex];
const pluginYamlURI = this.getPluginYampURI(registry, metadataInternal);
const pluginYamlURI = this.getPluginYamlURI(registry, metadataInternal);

try {
const pluginMetadata = await this.loadPluginMetadata(pluginYamlURI, longKeyFormat, registry.publicUri);
Expand Down Expand Up @@ -335,7 +335,7 @@ export class ChePluginServiceImpl implements ChePluginService {
* @param plugin plugin metadata
* @return uri to plugin yaml file
*/
private getPluginYampURI(registry: ChePluginRegistry, plugin: ChePluginMetadataInternal): string {
private getPluginYamlURI(registry: ChePluginRegistry, plugin: ChePluginMetadataInternal): string {
if (plugin.links && plugin.links.self) {
const self: string = plugin.links.self;
if (self.startsWith('/')) {
Expand Down