-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split initialize and configure into two separate sub-commands
- Loading branch information
1 parent
baad546
commit bc21ee5
Showing
29 changed files
with
540 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
6 changes: 3 additions & 3 deletions
6
ret-cli/src/main/kotlin/io/rabobank/ret/command/PluginCommand.kt
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package io.rabobank.ret.command | ||
|
||
import io.rabobank.ret.util.Logged | ||
import picocli.CommandLine.Command | ||
|
||
@Command( | ||
name = "plugin", | ||
description = ["Initialize or update RET plugins"], | ||
subcommands = [ | ||
PluginInitializeCommand::class, | ||
], | ||
subcommands = [PluginInitializeCommand::class], | ||
) | ||
@Logged | ||
class PluginCommand |
24 changes: 20 additions & 4 deletions
24
ret-cli/src/main/kotlin/io/rabobank/ret/command/PluginInitializeCommand.kt
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 |
---|---|---|
@@ -1,24 +1,40 @@ | ||
package io.rabobank.ret.command | ||
|
||
import io.quarkus.logging.Log | ||
import io.rabobank.ret.RetConsole | ||
import io.rabobank.ret.plugins.RetPlugin | ||
import io.rabobank.ret.util.Logged | ||
import picocli.CommandLine.Command | ||
import picocli.CommandLine.Model.CommandSpec | ||
import picocli.CommandLine.Parameters | ||
import picocli.CommandLine.Spec | ||
|
||
@Command( | ||
name = "initialize", | ||
description = ["Initialize plugin"], | ||
) | ||
class PluginInitializeCommand : Runnable { | ||
@Logged | ||
class PluginInitializeCommand( | ||
private val retConsole: RetConsole, | ||
) : Runnable { | ||
@Parameters( | ||
arity = "1", | ||
paramLabel = "<plugin file>", | ||
description = ["Absolute path to plugin"], | ||
) | ||
lateinit var pluginFile: String | ||
|
||
@Spec | ||
lateinit var commandSpec: CommandSpec | ||
|
||
override fun run() { | ||
System.load(pluginFile) | ||
val isolateThread = RetPlugin.createIsolate() | ||
RetPlugin.initialize(isolateThread, pluginFile) | ||
runCatching { | ||
System.load(pluginFile) | ||
val isolateThread = RetPlugin.createIsolate() | ||
RetPlugin.initialize(isolateThread, pluginFile) | ||
}.onFailure { | ||
retConsole.errorOut("Unable to load plugin file $pluginFile: ${it.message}") | ||
Log.error("Unable to load plugin file $pluginFile", it) | ||
}.getOrThrow() | ||
} | ||
} |
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
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
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
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
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
33 changes: 33 additions & 0 deletions
33
ret-core/src/main/kotlin/io/rabobank/ret/configuration/ConfigurablePlugin.kt
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,33 @@ | ||
package io.rabobank.ret.configuration | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.readValue | ||
import io.rabobank.ret.util.OsUtils | ||
import jakarta.enterprise.context.Dependent | ||
import jakarta.inject.Inject | ||
import org.eclipse.microprofile.config.inject.ConfigProperty | ||
|
||
/** | ||
* Extend from this base plugin class to help out with loading plugin specific configuration. | ||
* This class also implements [Configurable] with a default implementation of [properties] with an empty list. | ||
* | ||
* @see Configurable | ||
*/ | ||
@Dependent | ||
open class ConfigurablePlugin : Configurable { | ||
@ConfigProperty(name = "plugin.name", defaultValue = "ret") | ||
lateinit var pluginName: String | ||
|
||
@Inject | ||
lateinit var osUtils: OsUtils | ||
|
||
@Inject | ||
lateinit var objectMapper: ObjectMapper | ||
|
||
val config by lazy { | ||
runCatching { objectMapper.readValue<Map<String, String>>(osUtils.getPluginConfig(pluginName).toFile()) } | ||
.getOrDefault(emptyMap()) | ||
} | ||
|
||
override fun properties() = emptyList<ConfigurationProperty>() | ||
} |
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
Oops, something went wrong.