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

changed ssh connection type #233

Merged
merged 3 commits into from
May 27, 2024
Merged
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
34 changes: 21 additions & 13 deletions src/main/kotlin/com/vk/admstorm/startup/ChangeSshBackendStartup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,52 @@ import com.vk.admstorm.notifications.AdmNotification
object ChangeSshBackendStartup {
private val LOG = logger<ChangeSshBackendStartup>()

private const val SSH_NOTIFICATOR_OPTION = "sshLegacyChanges"
private const val LEGACY_SSH_NOTIFICATOR_OPTION = "sshLegacyChanges"
private const val SSH_NOTIFICATOR_OPTION = "sshOpenSSHChanges"
private const val SSH_CONFIG_BACKEND = "ssh.config.backend"

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

fun changeConfigurationProcess(project: Project) {
val dntShow = PropertiesComponent.getInstance(project).getBoolean(SSH_NOTIFICATOR_OPTION)
val properties = PropertiesComponent.getInstance(project)

val dntShow = properties.getBoolean(SSH_NOTIFICATOR_OPTION)
if (dntShow) {
LOG.info("LEGACY SSH option was enabled")
LOG.info("OPENSSH option was enabled")
return
}

//TODO: Remove it after 2 month
if (properties.isValueSet(LEGACY_SSH_NOTIFICATOR_OPTION)) {
properties.unsetValue(LEGACY_SSH_NOTIFICATOR_OPTION)
}

val sshSettingValue = AdvancedSettings.getEnum(SSH_CONFIG_BACKEND, SshConnectionConfigService.Kind::class.java)
if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) {
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
LOG.info("LEGACY SSH option was enabled before")
if (sshSettingValue == SshConnectionConfigService.Kind.OPENSSH) {
properties.setValue(SSH_NOTIFICATOR_OPTION, true)
LOG.info("OPENSSH option was enabled before")
return
}

changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
LOG.info("LEGACY SSH has been changed")
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
LOG.info("LEGACY SSH has been changed to OPENSSH")

AdmNotification("We changed your ssh type to LEGACY")
AdmNotification("We changed your ssh type to OPENSSH")
.withActions(
AdmNotification.Action("Don`t show it again") { _, notification ->
LOG.info("LEGACY SSH option has been set")
LOG.info("OPENSSH option has been set")
notification.expire()
}
).withActions(
AdmNotification.Action("Rollback and turn off this notification") { _, notification ->
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
LOG.info("SSH option changed to OpenSSH")
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
LOG.info("SSH option changed to LEGACY")
notification.expire()
}
).show(project)

PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
properties.setValue(SSH_NOTIFICATOR_OPTION, true)
}
}
Loading