Skip to content
Open
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions plugins/qodana/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package qodana

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/schema"
)

func New() schema.Plugin {
return schema.Plugin{
Name: "qodana",
Platform: schema.PlatformInfo{
Name: "Qodana",
Homepage: sdk.URL("https://qodana.cloud"),
},
Credentials: []schema.CredentialType{
ProjectToken(),
},
Executables: []schema.Executable{
QodanaCLI(),
},
}
}
33 changes: 33 additions & 0 deletions plugins/qodana/project_token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package qodana

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/importer"
"github.com/1Password/shell-plugins/sdk/provision"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

func ProjectToken() schema.CredentialType {
return schema.CredentialType{
Name: credname.APIToken,
DocsURL: sdk.URL("https://www.jetbrains.com/help/qodana/cloud-projects.html#cloud-manage-projects"),
ManagementURL: sdk.URL("https://qodana.cloud/"),
Fields: []schema.CredentialField{
{
Name: fieldname.Token,
MarkdownDescription: "Project token used to authenticate to Qodana Cloud.",
Secret: true,
},
},
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
Importer: importer.TryAll(
importer.TryEnvVarPair(defaultEnvVarMapping),
),
}
}

var defaultEnvVarMapping = map[string]sdk.FieldName{
"QODANA_TOKEN": fieldname.Token,
}
Comment thread
eddumelendez marked this conversation as resolved.
41 changes: 41 additions & 0 deletions plugins/qodana/project_token_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package qodana

import (
"testing"

"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/plugintest"
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

func TestProjectTokenImporter(t *testing.T) {
plugintest.TestImporter(t, ProjectToken().Importer, map[string]plugintest.ImportCase{
"QODANA_TOKEN environment variable": {
Environment: map[string]string{
"QODANA_TOKEN": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.EXAMPLE",
},
ExpectedCandidates: []sdk.ImportCandidate{
{
Fields: map[sdk.FieldName]string{
fieldname.Token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.EXAMPLE",
},
},
},
},
})
}
Comment on lines +11 to +26

func TestProjectTokenProvisioner(t *testing.T) {
plugintest.TestProvisioner(t, ProjectToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{
"default": {
ItemFields: map[sdk.FieldName]string{
fieldname.Token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.EXAMPLE",
},
ExpectedOutput: sdk.ProvisionOutput{
Environment: map[string]string{
"QODANA_TOKEN": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.EXAMPLE",
},
},
},
})
}
Comment thread
eddumelendez marked this conversation as resolved.
28 changes: 28 additions & 0 deletions plugins/qodana/qodana.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package qodana

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/needsauth"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
)

func QodanaCLI() schema.Executable {
return schema.Executable{
Name: "Qodana CLI",
Runs: []string{"qodana"},
DocsURL: sdk.URL("https://www.jetbrains.com/help/qodana/quick-start.html#quickstart-prerequisites-qodana-cli"),
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWhenContainsArgs("cloc"),
needsauth.NotWhenContainsArgs("completion"),
needsauth.NotWhenContainsArgs("contributors"),
Comment on lines +15 to +19
needsauth.NotWhenContainsArgs("pull"),
needsauth.NotWhenContainsArgs("show"),
needsauth.NotWhenContainsArgs("view"),
),
Uses: []schema.CredentialUsage{
{Name: credname.APIToken},
},
}
}