-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: snyk controller extension point
Add an extension point to allow third-party plugins to interact with Snyk in the IDE.
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<idea-plugin> | ||
<id>io.snyk.plugin</id> | ||
|
||
<extensionPoints> | ||
<extensionPoint | ||
name="controllerLifecycleManager" | ||
interface="io.snyk.plugin.extensionpoints.SnykControllerLifecycleManager"/> | ||
</extensionPoints> | ||
|
||
</idea-plugin> |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/io/snyk/plugin/extensionpoints/SnykController.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,20 @@ | ||
package io.snyk.plugin.extensionpoints | ||
|
||
import com.intellij.openapi.project.Project | ||
import io.snyk.plugin.getSnykApiService | ||
import io.snyk.plugin.getSnykTaskQueueService | ||
import org.apache.commons.lang3.NotImplementedException | ||
|
||
// SnykController is used by third-party plugins to interact with the Snyk plugin. | ||
sealed class SnykController { | ||
// scan enqueues a scan of the project for vulnerabilities. | ||
fun scan(project: Project) { | ||
getSnykTaskQueueService(project)?.scan(); | ||
Check warning Code scanning / detekt Detects semicolons Warning
Unnecessary semicolon
|
||
} | ||
|
||
// userId returns the current authenticated Snyk user's ID. | ||
// If no user is authenticated, this will return null. | ||
fun userId(): String? { | ||
return getSnykApiService().userId; | ||
Check warning Code scanning / detekt Detects semicolons Warning
Unnecessary semicolon
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/io/snyk/plugin/extensionpoints/SnykControllerLifecycleManager.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,11 @@ | ||
package io.snyk.plugin.extensionpoints | ||
|
||
// SnykControllerLifecycleManager is the extension point interface | ||
// which other plugins can implement in order to integrate with Snyk. | ||
interface SnykControllerLifecycleManager { | ||
|
||
// register is called by Snyk on third-party implementations of this interface | ||
// to give the calling plugin an instance of SnykController which can be used | ||
// to control Snyk in the IDE. | ||
fun register(controller: SnykController) | ||
} |