Skip to content

Commit 2016770

Browse files
authored
Merge pull request #605 from eddumelendez/kiro-support
Add Kiro shell plugin
2 parents 1d0b5fe + 3c8fff1 commit 2016770

4 files changed

Lines changed: 131 additions & 0 deletions

File tree

plugins/kiro/api_key.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package kiro
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/importer"
6+
"github.com/1Password/shell-plugins/sdk/provision"
7+
"github.com/1Password/shell-plugins/sdk/schema"
8+
"github.com/1Password/shell-plugins/sdk/schema/credname"
9+
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
10+
)
11+
12+
func APIKey() schema.CredentialType {
13+
return schema.CredentialType{
14+
Name: credname.APIKey,
15+
DocsURL: sdk.URL("https://kiro.dev/docs/cli/authentication/"),
16+
ManagementURL: sdk.URL("https://app.kiro.dev"),
17+
Fields: []schema.CredentialField{
18+
{
19+
Name: fieldname.APIKey,
20+
MarkdownDescription: "API Key used to authenticate to Kiro.",
21+
Secret: true,
22+
Composition: &schema.ValueComposition{
23+
Prefix: "ksk_",
24+
Charset: schema.Charset{
25+
Uppercase: true,
26+
Lowercase: true,
27+
Digits: true,
28+
},
29+
},
30+
},
31+
},
32+
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
33+
Importer: importer.TryEnvVarPair(defaultEnvVarMapping),
34+
}
35+
}
36+
37+
var defaultEnvVarMapping = map[string]sdk.FieldName{
38+
"KIRO_API_KEY": fieldname.APIKey,
39+
}

plugins/kiro/api_key_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package kiro
2+
3+
import (
4+
"testing"
5+
6+
"github.com/1Password/shell-plugins/sdk"
7+
"github.com/1Password/shell-plugins/sdk/plugintest"
8+
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
9+
)
10+
11+
const exampleAPIKey = "ksk_12345678"
12+
13+
func TestAPIKeyProvisioner(t *testing.T) {
14+
plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{
15+
"default": {
16+
ItemFields: map[sdk.FieldName]string{
17+
fieldname.APIKey: exampleAPIKey,
18+
},
19+
ExpectedOutput: sdk.ProvisionOutput{
20+
Environment: map[string]string{
21+
"KIRO_API_KEY": exampleAPIKey,
22+
},
23+
},
24+
},
25+
})
26+
}
27+
28+
func TestAPIKeyImporter(t *testing.T) {
29+
plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{
30+
"environment": {
31+
Environment: map[string]string{
32+
"KIRO_API_KEY": exampleAPIKey,
33+
},
34+
ExpectedCandidates: []sdk.ImportCandidate{
35+
{
36+
Fields: map[sdk.FieldName]string{
37+
fieldname.APIKey: exampleAPIKey,
38+
},
39+
},
40+
},
41+
},
42+
})
43+
}

plugins/kiro/kiro.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package kiro
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/needsauth"
6+
"github.com/1Password/shell-plugins/sdk/schema"
7+
"github.com/1Password/shell-plugins/sdk/schema/credname"
8+
)
9+
10+
func KiroCLI() schema.Executable {
11+
return schema.Executable{
12+
Name: "Kiro CLI",
13+
Runs: []string{"kiro-cli"},
14+
DocsURL: sdk.URL("https://kiro.dev/docs/cli/"),
15+
NeedsAuth: needsauth.IfAll(
16+
needsauth.NotForHelpOrVersion(),
17+
needsauth.NotWithoutArgs(),
18+
needsauth.NotWhenContainsArgs("login"),
19+
needsauth.NotWhenContainsArgs("logout"),
20+
),
21+
Uses: []schema.CredentialUsage{
22+
{
23+
Name: credname.APIKey,
24+
},
25+
},
26+
}
27+
}

plugins/kiro/plugin.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package kiro
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/schema"
6+
)
7+
8+
func New() schema.Plugin {
9+
return schema.Plugin{
10+
Name: "kiro",
11+
Platform: schema.PlatformInfo{
12+
Name: "Kiro",
13+
Homepage: sdk.URL("https://kiro.dev"),
14+
},
15+
Credentials: []schema.CredentialType{
16+
APIKey(),
17+
},
18+
Executables: []schema.Executable{
19+
KiroCLI(),
20+
},
21+
}
22+
}

0 commit comments

Comments
 (0)