Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show target selection dialog when there is no config #199

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
t4lz marked this conversation as resolved.
Show resolved Hide resolved
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")
t4lz marked this conversation as resolved.
Show resolved Hide resolved

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