Skip to content

Commit

Permalink
ktlint format
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed Oct 16, 2023
1 parent 7ad3d24 commit 21fad45
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class MirrordApi(private val service: MirrordProjectService) {
when {
message.name == "mirrord preparing to launch" && message.type == MessageType.FinishedTask -> {
val success = message.success
?: throw MirrordError("invalid message received from the mirrord binary")
?: throw MirrordError("invalid message received from the mirrord binary")
if (success) {
val innerMessage = message.message
?: throw MirrordError("invalid message received from the mirrord binary")
?: throw MirrordError("invalid message received from the mirrord binary")
val executionInfo = parser.parse(innerMessage, MirrordExecution::class.java)
setText("mirrord is running")
return executionInfo
Expand Down Expand Up @@ -282,7 +282,7 @@ private abstract class MirrordCliTask<T>(private val cli: String, private val co
environment["MIRRORD_PROGRESS_MODE"] = "json"

for (entry in environment.entries) {
MirrordLogger.logger.info("environment var ${entry}")
MirrordLogger.logger.info("environment var $entry")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class MirrordBinaryManager {
* Should be false if wslDistribution is unknown
*/
private class UpdateTask(
private val project: Project,
private val product: String?,
private val wslDistribution: WSLDistribution?,
private val checkInPath: Boolean
private val project: Project,
private val product: String?,
private val wslDistribution: WSLDistribution?,
private val checkInPath: Boolean
) : Task.Backgroundable(project, "mirrord", true), DumbAware {
companion object State {
/**
Expand Down Expand Up @@ -86,10 +86,10 @@ class MirrordBinaryManager {
userSelectedMirrordVersion
} else {
project
.service<MirrordProjectService>()
.notifier
.notification("mirrord version format is invalid!", NotificationType.WARNING)
.fire()
.service<MirrordProjectService>()
.notifier
.notification("mirrord version format is invalid!", NotificationType.WARNING)
.fire()
return
}
}
Expand All @@ -112,8 +112,8 @@ class MirrordBinaryManager {
}

manager.latestSupportedVersion = version
// auto update -> false -> mirrordVersion is empty -> no cli found locally -> fetch latest version
?: manager.fetchLatestSupportedVersion(product, indicator)
// auto update -> false -> mirrordVersion is empty -> no cli found locally -> fetch latest version
?: manager.fetchLatestSupportedVersion(product, indicator)

if (downloadInProgress.compareAndExchange(false, true)) {
return
Expand All @@ -127,8 +127,8 @@ class MirrordBinaryManager {
MirrordLogger.logger.debug("binary update task failed", error)

project.service<MirrordProjectService>()
.notifier
.notifyRichError("failed to update the mirrord binary: ${error.message ?: error.toString()}")
.notifier
.notifyRichError("failed to update the mirrord binary: ${error.message ?: error.toString()}")
}

override fun onFinished() {
Expand All @@ -140,12 +140,12 @@ class MirrordBinaryManager {
override fun onSuccess() {
downloadingVersion?.let {
project
.service<MirrordProjectService>()
.notifier
.notifySimple(
"downloaded mirrord binary version $downloadingVersion",
NotificationType.INFORMATION
)
.service<MirrordProjectService>()
.notifier
.notifySimple(
"downloaded mirrord binary version $downloadingVersion",
NotificationType.INFORMATION
)
}
}

Expand All @@ -160,8 +160,8 @@ class MirrordBinaryManager {

private fun fetchLatestSupportedVersion(product: String?, indicator: ProgressIndicator): String {
val pluginVersion = if (
System.getenv("CI_BUILD_PLUGIN") == "true" ||
System.getenv("PLUGIN_TESTING_ENVIRONMENT") == "true"
System.getenv("CI_BUILD_PLUGIN") == "true" ||
System.getenv("PLUGIN_TESTING_ENVIRONMENT") == "true"
) {
"test"
} else {
Expand All @@ -171,18 +171,18 @@ class MirrordBinaryManager {
indicator.text = "mirrord is checking the latest supported binary version..."

val url = StringBuilder(VERSION_ENDPOINT)
.append("?source=3")
.append("&version=")
.append(URLEncoder.encode(pluginVersion, Charset.defaultCharset()))
.append("&platform=")
.append(URLEncoder.encode(SystemInfo.OS_NAME, Charset.defaultCharset()))
.toString()
.append("?source=3")
.append("&version=")
.append(URLEncoder.encode(pluginVersion, Charset.defaultCharset()))
.append("&platform=")
.append(URLEncoder.encode(SystemInfo.OS_NAME, Charset.defaultCharset()))
.toString()

val client = HttpClient.newHttpClient()
val builder = HttpRequest
.newBuilder(URI(url))
.timeout(Duration.ofSeconds(10L))
.GET()
.newBuilder(URI(url))
.timeout(Duration.ofSeconds(10L))
.GET()

product?.let { builder.header("user-agent", it) }

Expand Down Expand Up @@ -334,18 +334,18 @@ class MirrordBinaryManager {
} ?: "using a possibly outdated local installation with version ${it.version}"

project
.service<MirrordProjectService>()
.notifier
.notification(message, NotificationType.WARNING)
.withDontShowAgain(MirrordSettingsState.NotificationId.POSSIBLY_OUTDATED_BINARY_USED)
.fire()
.service<MirrordProjectService>()
.notifier
.notification(message, NotificationType.WARNING)
.withDontShowAgain(MirrordSettingsState.NotificationId.POSSIBLY_OUTDATED_BINARY_USED)
.fire()

return it.command
}

throw MirrordError(
"no local installation of mirrord binary was found",
"mirrord binary will be downloaded in the background"
"no local installation of mirrord binary was found",
"mirrord binary will be downloaded in the background"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ class MirrordExecManager(private val service: MirrordProjectService) {
* @throws ProcessCanceledException if the dialog cannot be displayed
*/
private fun chooseTarget(
cli: String,
wslDistribution: WSLDistribution?,
config: String?
cli: String,
wslDistribution: WSLDistribution?,
config: String?
): String {
MirrordLogger.logger.debug("choose target called")

val pods = service.mirrordApi.listPods(
cli,
config,
wslDistribution
cli,
config,
wslDistribution
)

val application = ApplicationManager.getApplication()
Expand All @@ -50,27 +50,27 @@ class MirrordExecManager(private val service: MirrordProjectService) {
MirrordLogger.logger.debug("read lock detected, aborting target selection")

service
.notifier
.notification(
"mirrord plugin was unable to display the target selection dialog. " +
"You can set it manually in the configuration file $config.",
NotificationType.WARNING
)
.apply {
val configFile = try {
val path = Path.of(config)
VirtualFileManager.getInstance().findFileByNioPath(path)
} catch (e: Exception) {
MirrordLogger.logger.debug("failed to find config under path $config", e)
null
}

configFile?.let {
withOpenFile(it)
}
.notifier
.notification(
"mirrord plugin was unable to display the target selection dialog. " +
"You can set it manually in the configuration file $config.",
NotificationType.WARNING
)
.apply {
val configFile = try {
val path = Path.of(config)
VirtualFileManager.getInstance().findFileByNioPath(path)
} catch (e: Exception) {
MirrordLogger.logger.debug("failed to find config under path $config", e)
null
}
.withLink("Config doc", "https://mirrord.dev/docs/overview/configuration/#root-target")
.fire()

configFile?.let {
withOpenFile(it)
}
}
.withLink("Config doc", "https://mirrord.dev/docs/overview/configuration/#root-target")
.fire()

null
}
Expand All @@ -91,10 +91,10 @@ class MirrordExecManager(private val service: MirrordProjectService) {
* @throws ProcessCanceledException if the user cancelled
*/
private fun start(
wslDistribution: WSLDistribution?,
executable: String?,
product: String,
mirrordConfigFromEnv: String?
wslDistribution: WSLDistribution?,
executable: String?,
product: String,
mirrordConfigFromEnv: String?
): Pair<Map<String, String>, String?>? {
if (!service.enabled) {
MirrordLogger.logger.debug("disabled, returning")
Expand Down Expand Up @@ -135,21 +135,21 @@ class MirrordExecManager(private val service: MirrordProjectService) {
if (target == MirrordExecDialog.targetlessTargetName) {
MirrordLogger.logger.info("No target specified - running targetless")
service.notifier.notification(
"No target specified, mirrord running targetless.",
NotificationType.INFORMATION
"No target specified, mirrord running targetless.",
NotificationType.INFORMATION
)
.withDontShowAgain(MirrordSettingsState.NotificationId.RUNNING_TARGETLESS)
.fire()
.withDontShowAgain(MirrordSettingsState.NotificationId.RUNNING_TARGETLESS)
.fire()
target = null
}
}

val executionInfo = service.mirrordApi.exec(
cli,
target,
config,
executable,
wslDistribution
cli,
target,
config,
executable,
wslDistribution
)

executionInfo.environment["MIRRORD_IGNORE_DEBUGGER_PORTS"] = "35000-65535"
Expand Down

0 comments on commit 21fad45

Please sign in to comment.