-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): enhance plugin management
Changes: * add new interface PluginManager * add new CLI for un-installing plugins * refactor service for downloading plugins * refactor PluginController
- Loading branch information
1 parent
42ad09d
commit bb7cc38
Showing
21 changed files
with
1,182 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 54 additions & 54 deletions
108
cli/src/main/java/io/kestra/cli/commands/plugins/PluginInstallCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
cli/src/main/java/io/kestra/cli/commands/plugins/PluginUninstallCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.kestra.cli.commands.plugins; | ||
|
||
import io.kestra.cli.AbstractCommand; | ||
import io.kestra.core.plugins.LocalPluginManager; | ||
import io.kestra.core.plugins.MavenPluginRepository; | ||
import io.kestra.core.plugins.PluginArtifact; | ||
import io.kestra.core.plugins.PluginManager; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Provider; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.Parameters; | ||
import picocli.CommandLine.Spec; | ||
|
||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@CommandLine.Command( | ||
name = "uninstall", | ||
description = "uninstall a plugin" | ||
) | ||
public class PluginUninstallCommand extends AbstractCommand { | ||
@Parameters(index = "0..*", description = "the plugins to uninstall") | ||
List<String> dependencies = new ArrayList<>(); | ||
|
||
@Spec | ||
CommandLine.Model.CommandSpec spec; | ||
|
||
@Inject | ||
Provider<MavenPluginRepository> mavenPluginRepositoryProvider; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
super.call(); | ||
|
||
List<PluginArtifact> pluginArtifacts; | ||
try { | ||
pluginArtifacts = dependencies.stream().map(PluginArtifact::fromCoordinates).toList(); | ||
} catch (IllegalArgumentException e) { | ||
stdErr(e.getMessage()); | ||
return CommandLine.ExitCode.USAGE; | ||
} | ||
|
||
final PluginManager pluginManager; | ||
|
||
// If a PLUGIN_PATH is provided, then use the LocalPluginManager | ||
if (pluginsPath != null) { | ||
pluginManager = new LocalPluginManager(mavenPluginRepositoryProvider.get()); | ||
} else { | ||
// Otherwise, we delegate to the configured plugin-manager. | ||
pluginManager = this.pluginManagerProvider.get(); | ||
} | ||
|
||
List<PluginArtifact> uninstalled = pluginManager.uninstall( | ||
pluginArtifacts, | ||
false, | ||
pluginsPath | ||
); | ||
|
||
List<URI> uris = uninstalled.stream().map(PluginArtifact::uri).toList(); | ||
stdOut("Successfully uninstalled plugins {0} from {1}", dependencies, uris); | ||
return CommandLine.ExitCode.OK; | ||
} | ||
|
||
@Override | ||
protected boolean loadExternalPlugins() { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.