Skip to content

Commit

Permalink
Add mirrord IntelliJ extension (#266)
Browse files Browse the repository at this point in the history
* Add mirrord intellij extension
  • Loading branch information
infiniteregrets authored Aug 28, 2022
1 parent 922e145 commit 9add52c
Show file tree
Hide file tree
Showing 25 changed files with 886 additions and 5 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
go build
- run: |
cd tests/go-e2e-fileops
go build
go build
- name: start minikube
uses: medyagh/setup-minikube@master
with:
Expand Down Expand Up @@ -218,3 +218,18 @@ jobs:
- name: Collect container logs
if: ${{ failure() }}
run: for CONTAINER in $(docker ps --format "{{.ID}}"); do echo $CONTAINER && docker logs $CONTAINER; done

build_intellij_plugin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Build Plugin
run: |
cd intellij-ext
chmod +x ./gradlew
./gradlew buildPlugin
36 changes: 32 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
ghcr.io/metalbear-co/mirrord:${{ steps.version.outputs.version }}
release_vscode_ext:
needs: [build_binaries, build_binaries_macos, release_docker_image]
needs: [ build_binaries, build_binaries_macos, release_docker_image ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -124,12 +124,12 @@ jobs:
id: version
- run: npm install -g vsce typescript esbuild
- run: cp CHANGELOG.md LICENSE vscode-ext/
- run: mv /tmp/artifacts/x86_64-unknown-linux-gnu/libmirrord_layer.so vscode-ext/
- run: cp /tmp/artifacts/x86_64-unknown-linux-gnu/libmirrord_layer.so vscode-ext/
- run: cd vscode-ext && npm install && tsc && vsce publish ${{ steps.version.outputs.version }} --target linux-x64
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- run: rm vscode-ext/libmirrord_layer.so
- run: mv /tmp/artifacts/universal-apple-darwin/libmirrord_layer.dylib vscode-ext/
- run: cp /tmp/artifacts/universal-apple-darwin/libmirrord_layer.dylib vscode-ext/
# Same binary for darwin
- run: cd vscode-ext && npm install && tsc && vsce publish ${{ steps.version.outputs.version }} --target darwin-x64
env:
Expand All @@ -138,8 +138,36 @@ jobs:
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}


release_intellij_plugin:
needs: [ build_binaries, build_binaries_macos, release_docker_image ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
path: /tmp/artifacts
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- run: cp LICENSE intellij-ext/
- run: cp /tmp/artifacts/x86_64-unknown-linux-gnu/libmirrord_layer.* intellij-ext/
- name: Publish Plugin
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: |
cd intellij-ext
chmod +x ./gradlew
./gradlew publishPlugin
release_gh:
needs: [build_binaries, build_binaries_macos, release_docker_image, release_vscode_ext]
needs: [ build_binaries, build_binaries_macos, release_docker_image, release_vscode_ext ]
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ tests/go-e2e-fileops/go-e2e-fileops
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### Intellij ###
intellij-ext/.gradle
intellij-ext/.idea
intellij-ext/.qodana
intellij-ext/build
intellij-ext/libmirrord_layer.*
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

### Added
- Support for Golang fileops
- IntelliJ Extension for mirrord

### Changed
- mirrord-layer: Added common `Result` type to to reduce boilerplate, removed dependency of `anyhow` crate.
Expand Down
30 changes: 30 additions & 0 deletions intellij-ext/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# mirrord

<!-- Plugin description -->
mirrord works by letting you select a pod to mirror traffic from. It launches a privileged pod on the same node which enters the namespace of the selected pod and captures traffic from it.
### How To Use

* Click "Enable/Disable mirrord" toggle button on the run tool window.
* Start debugging your project
* Choose pod to mirror traffic from, select and configure mirrord options.
* The debugged process will start with mirrord, and receive traffic.

<!-- Plugin description end -->

## Installation

- Using IDE built-in plugin system:

<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "mirrord-intellij-plugin"</kbd> >
<kbd>Install Plugin</kbd>

- Manually:

Download the latest release and install it manually using
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd>


---
Plugin based on the [IntelliJ Platform Plugin Template][template].

[template]: https://github.com/JetBrains/intellij-platform-plugin-template
120 changes: 120 additions & 0 deletions intellij-ext/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun properties(key: String) = project.findProperty(key).toString()

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.6.10"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.8.1"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
}

group = properties("pluginGroup")
version = properties("pluginVersion")

// Configure project's dependencies
repositories {
mavenCentral()
}
dependencies {
implementation("io.kubernetes:client-java:16.0.0") {
exclude(group="org.slf4j", module = "slf4j-api")
}
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
}

// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath.set(projectDir.resolve(".qodana").canonicalPath)
reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath)
saveReport.set(true)
showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false)
}

tasks {
// Set the JVM compatibility versions
properties("javaVersion").let {
withType<JavaCompile> {
sourceCompatibility = it
targetCompatibility = it
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = it
}
}

wrapper {
gradleVersion = properties("gradleVersion")
}

patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
)
}

prepareSandbox {
doLast {
copy {
from(file("$projectDir/libmirrord_layer.dylib"))
into(file("$buildDir/idea-sandbox/config"))
}
copy {
from(file("$projectDir/libmirrord_layer.so"))
into(file("$buildDir/idea-sandbox/config"))
}
}
}

// Configure UI tests plugin
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
runIdeForUiTests {
systemProperty("robot-server.port", "8082")
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf("beta"))
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
}
}
30 changes: 30 additions & 0 deletions intellij-ext/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# IntelliJ Platform Artifacts Repositories
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = com.metalbear.mirrord
pluginName = mirrord
# SemVer format -> https://semver.org
pluginVersion = 2.7.4

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 213
pluginUntilBuild = 222.*

platformType = IC
platformVersion = 2021.3.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins =

# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 11

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.5.1

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false
Binary file added intellij-ext/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions intellij-ext/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 9add52c

Please sign in to comment.