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

Allow using the che-plugin-broker as a library in the Workspace CRD controller #38

Merged
merged 9 commits into from
Mar 26, 2019

Conversation

davidfestal
Copy link
Contributor

@davidfestal davidfestal commented Mar 21, 2019

What does this PR do?

This PR introduces minimal changes to allow using the che-plugin-broker as a library in the Workspace CRD Controller Proof of concept.

Added 2 global configuration options to :

  • allow skipping the copy of files in the /plugins directory (when we are only interested in generating the ToolingConf metadata)
  • allow using localhost instead of the service name in the endpoint URL of the Theia or VSCode plugins

Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursory first look from someone who perhaps isn't as familiar with the plugin broker as they should be.

brokers/che-plugin-broker/broker.go Outdated Show resolved Hide resolved
@@ -130,10 +130,10 @@ func (b *Broker) processPlugin(meta model.PluginMeta) error {
}
if pluginImage == "" {
// regular plugin
return b.injectTheiaFile(meta, archivePath)
return b.injectTheiaFile(meta, archivePath, onlyMetadata)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this method is to inject file. It is better to refactor code instead of just adding boolean parameter to it. And with the remote plugin the problem is the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that some refactoring might be useful, but my idea was mainly to change the structure of the code as less as possible, knowing that a number of changes are ongoing or planned. I would have let the refactoring phase for the upcoming changes planned in the context of meta.yaml and plugin yaml merge.

@@ -53,7 +54,11 @@ func AddExtension(toolingConf *model.ToolingConf, pj model.PackageJSON) {
sidecarEndpoint := toolingConf.Endpoints[0]
prettyID := re.ReplaceAllString(pj.Publisher+"_"+pj.Name, `_`)
sidecarTheiaEnvVarName := "THEIA_PLUGIN_REMOTE_ENDPOINT_" + prettyID
sidecarTheiaEnvVarValue := "ws://" + sidecarEndpoint.Name + ":" + strconv.Itoa(sidecarEndpoint.TargetPort)
sidecarHostname := sidecarEndpoint.Name
if cfg.UseLocalhostInPluginUrls {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was designing this utility it was supposed to not interact with config package. In fact, interacting with the config package is like using global variables.

Copy link
Contributor Author

@davidfestal davidfestal Mar 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what it is: a global setting that is taken into account every time we build an endpoint URL. BTW this global setting is only changed when the brokers are used as a library, so no change for your use-case.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'm more concerned about maintainability of the codebase rather than any particular case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this concern could be tackled in the context of one of the future PRs that are still expected in the upcoming refactoring work on the che-plugin-broker ?

I tried to reduce the changes in this PR to the minimum, and in a way that introduce only local non-invasive changes.

brokers/vscode/broker.go Outdated Show resolved Hide resolved
@davidfestal davidfestal requested a review from l0rd March 22, 2019 09:09
davidfestal added a commit to devfile/devworkspace-operator that referenced this pull request Mar 22, 2019
Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
…oker

Conflicts:
	brokers/theia/broker.go
	brokers/vscode/broker.go
Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
@davidfestal
Copy link
Contributor Author

@amisevsk @ibuziuk @garagatyi @l0rd Could you review the PR again please ?

Copy link
Member

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I think using cfg more widely is not much of an issue, but adding options to config could potentially make the code more complex.

@davidfestal davidfestal merged commit 17f0165 into eclipse-che:master Mar 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants