Skip to content

Commit 95eea9e

Browse files
authored
changed ssh connection type (#233)
1 parent caa96d5 commit 95eea9e

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/main/kotlin/com/vk/admstorm/startup/ChangeSshBackendStartup.kt

+21-13
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,52 @@ import com.vk.admstorm.notifications.AdmNotification
1010
object ChangeSshBackendStartup {
1111
private val LOG = logger<ChangeSshBackendStartup>()
1212

13-
private const val SSH_NOTIFICATOR_OPTION = "sshLegacyChanges"
13+
private const val LEGACY_SSH_NOTIFICATOR_OPTION = "sshLegacyChanges"
14+
private const val SSH_NOTIFICATOR_OPTION = "sshOpenSSHChanges"
1415
private const val SSH_CONFIG_BACKEND = "ssh.config.backend"
1516

1617
private fun changeSshConfiguration(configValue: SshConnectionConfigService.Kind) {
1718
AdvancedSettings.setEnum(SSH_CONFIG_BACKEND, configValue)
1819
}
1920

2021
fun changeConfigurationProcess(project: Project) {
21-
val dntShow = PropertiesComponent.getInstance(project).getBoolean(SSH_NOTIFICATOR_OPTION)
22+
val properties = PropertiesComponent.getInstance(project)
23+
24+
val dntShow = properties.getBoolean(SSH_NOTIFICATOR_OPTION)
2225
if (dntShow) {
23-
LOG.info("LEGACY SSH option was enabled")
26+
LOG.info("OPENSSH option was enabled")
2427
return
2528
}
2629

30+
//TODO: Remove it after 2 month
31+
if (properties.isValueSet(LEGACY_SSH_NOTIFICATOR_OPTION)) {
32+
properties.unsetValue(LEGACY_SSH_NOTIFICATOR_OPTION)
33+
}
34+
2735
val sshSettingValue = AdvancedSettings.getEnum(SSH_CONFIG_BACKEND, SshConnectionConfigService.Kind::class.java)
28-
if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) {
29-
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
30-
LOG.info("LEGACY SSH option was enabled before")
36+
if (sshSettingValue == SshConnectionConfigService.Kind.OPENSSH) {
37+
properties.setValue(SSH_NOTIFICATOR_OPTION, true)
38+
LOG.info("OPENSSH option was enabled before")
3139
return
3240
}
3341

34-
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
35-
LOG.info("LEGACY SSH has been changed")
42+
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
43+
LOG.info("LEGACY SSH has been changed to OPENSSH")
3644

37-
AdmNotification("We changed your ssh type to LEGACY")
45+
AdmNotification("We changed your ssh type to OPENSSH")
3846
.withActions(
3947
AdmNotification.Action("Don`t show it again") { _, notification ->
40-
LOG.info("LEGACY SSH option has been set")
48+
LOG.info("OPENSSH option has been set")
4149
notification.expire()
4250
}
4351
).withActions(
4452
AdmNotification.Action("Rollback and turn off this notification") { _, notification ->
45-
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
46-
LOG.info("SSH option changed to OpenSSH")
53+
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
54+
LOG.info("SSH option changed to LEGACY")
4755
notification.expire()
4856
}
4957
).show(project)
5058

51-
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
59+
properties.setValue(SSH_NOTIFICATOR_OPTION, true)
5260
}
5361
}

0 commit comments

Comments
 (0)