Skip to content

Commit

Permalink
show target selection dialog when there is no config (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
t4lz authored Nov 23, 2023
1 parent 88039fe commit 78cf440
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/198.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No target selection dialog was displayed when running without configuration.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class InvalidConfigException(path: String, reason: String) : MirrordError("faile
* @throws InvalidConfigException if config cannot be found or parsed.
*/
fun isTargetSet(config: String?): Boolean {
config ?: return false
val gson = Gson()

// `path` will be either a normal string, or the string `"null"` due to `toString`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class MirrordExecManager(private val service: MirrordProjectService) {
// Find the mirrord config path, then call `mirrord verify-config {path}` so we can display warnings/errors
// from the config without relying on mirrord-layer.
val configPath = service.configApi.getConfigPath(mirrordConfigFromEnv)
MirrordLogger.logger.debug("MirrordExecManager.start: config path is $cli")
MirrordLogger.logger.debug("MirrordExecManager.start: config path is $configPath")

val verifiedConfig = configPath?.let {
val verifiedConfigOutput =
Expand All @@ -131,7 +131,9 @@ class MirrordExecManager(private val service: MirrordProjectService) {

MirrordLogger.logger.debug("Verified Config: $verifiedConfig, Target selection.")

val target = if (configPath != null && !isTargetSet(verifiedConfig?.config)) {
val targetSet = verifiedConfig?.let { isTargetSet(it.config) } ?: false
val target = if (!targetSet) {
// There is no config file or the config does not specify a target, so show dialog.
MirrordLogger.logger.debug("target not selected, showing dialog")
chooseTarget(cli, wslDistribution, configPath).also {
if (it == MirrordExecDialog.targetlessTargetName) {
Expand Down

0 comments on commit 78cf440

Please sign in to comment.