generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
128 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
ide-common/src/main/kotlin/org/digma/intellij/plugin/docker/DockerComposeFileMigration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.digma.intellij.plugin.docker | ||
|
||
import com.intellij.openapi.diagnostic.Logger | ||
import org.digma.intellij.plugin.common.findActiveProject | ||
import org.digma.intellij.plugin.errorreporting.ErrorReporter | ||
import org.digma.intellij.plugin.log.Log | ||
import org.digma.intellij.plugin.persistence.PersistenceService | ||
import org.digma.intellij.plugin.posthog.ActivityMonitor | ||
import java.io.File | ||
|
||
|
||
fun migrateDockerComposeFile(newDockerComposeFilePath: String, logger: Logger) { | ||
|
||
/* | ||
in version 2.0.404 of the plugin we changed the location of the docker-conmpose.yml file. | ||
from $TEMP/digma-docker/docker-compose.yml | ||
to | ||
${DigmaPathManager.getLocalFilesDirectoryPath()}/digma-docker/docker-compose.yml | ||
when this plugin version is installed we try to find the old compose file and just copy it to the new location. | ||
after that local engine will continue to work as usual. | ||
if the old file does not exist: | ||
- if local engine is not installed, nothing to do. | ||
- if local engine is installed and not running: | ||
the next time user starts the engine the new file that is bundled with this plugin version will be used. | ||
this may be an update to the engine if the previous engine was older than the compose file that is bundled with this plugin version. | ||
- if local engine is installed and running: | ||
the next time user will try to stop the engine the new file that is bundled with this plugin version will be used. | ||
this may not succeed if the engine was installed with a much older version than what is bundled with this plugin version. | ||
if the steps above succeed local engine will continue to work as usual. | ||
*/ | ||
|
||
// this is a one time operation, if it fails we don't want to try again. | ||
// this code will run once after the installation of plugin version that contains this code. | ||
|
||
try { | ||
//check if this is the first time this plugin version is running | ||
val isFirstRunAfterPersistDockerCompose = PersistenceService.getInstance().isFirstRunAfterPersistDockerCompose() | ||
if (isFirstRunAfterPersistDockerCompose) { | ||
Log.log(logger::info, "first run after persist docker compose") | ||
PersistenceService.getInstance().setIsFirstRunAfterPersistDockerComposeDone() | ||
|
||
if (!PersistenceService.getInstance().isLocalEngineInstalled()) { | ||
Log.log(logger::info, "local engine not installed, nothing to do") | ||
return | ||
} | ||
|
||
val oldDockerComposeDir = File(System.getProperty("java.io.tmpdir"), COMPOSE_FILE_DIR_NAME) | ||
val oldDockerComposeFile = File(oldDockerComposeDir, COMPOSE_FILE_NAME) | ||
if (oldDockerComposeFile.exists()) { | ||
val newDockerComposeFile = File(newDockerComposeFilePath) | ||
Log.log(logger::info, "old compose file found, moving to new location {}", newDockerComposeFile) | ||
oldDockerComposeFile.copyTo(newDockerComposeFile, overwrite = true) | ||
//do not delete the old file, it may be used by other IDEs. worst case it will stay as zombie file in the user's temp directory | ||
////oldDockerComposeFile.delete() | ||
Log.log(logger::info, "old compose file moved to new location {}", newDockerComposeFile) | ||
} else { | ||
Log.log(logger::info, "old compose file not found") | ||
} | ||
|
||
findActiveProject()?.let { | ||
ActivityMonitor.getInstance(it).registerCustomEvent( | ||
"migrated docker compose file", mapOf( | ||
"oldDockerComposeFileExists" to oldDockerComposeFile.exists() | ||
) | ||
) | ||
} | ||
|
||
} | ||
} catch (e: Throwable) { | ||
Log.warnWithException(logger, e, "error migrating docker compose file") | ||
ErrorReporter.getInstance().reportError("DockerComposeFileMigration.migrateDockerComposeFile", e) | ||
} | ||
} | ||
|
||
|
168 changes: 0 additions & 168 deletions
168
...rc/main/kotlin/org/digma/intellij/plugin/docker/DockerComposePersistenceFeatureService.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.