File tree Expand file tree Collapse file tree 4 files changed +128
-0
lines changed
Expand file tree Collapse file tree 4 files changed +128
-0
lines changed Original file line number Diff line number Diff line change 1+ package localstack
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://docs.localstack.cloud/getting-started/api-key/" ),
16+ ManagementURL : sdk .URL ("https://app.localstack.cloud/account/apikeys" ),
17+ Fields : []schema.CredentialField {
18+ {
19+ Name : fieldname .APIKey ,
20+ MarkdownDescription : "API Key used to authenticate to LocalStack." ,
21+ Secret : true ,
22+ Composition : & schema.ValueComposition {
23+ Length : 10 ,
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 .TryAll (
34+ importer .TryEnvVarPair (defaultEnvVarMapping ),
35+ )}
36+ }
37+
38+ var defaultEnvVarMapping = map [string ]sdk.FieldName {
39+ "LOCALSTACK_API_KEY" : fieldname .APIKey ,
40+ }
Original file line number Diff line number Diff line change 1+ package localstack
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+ func TestAPIKeyProvisioner (t * testing.T ) {
12+ plugintest .TestProvisioner (t , APIKey ().DefaultProvisioner , map [string ]plugintest.ProvisionCase {
13+ "default" : {
14+ ItemFields : map [sdk.FieldName ]string {
15+ fieldname .APIKey : "SzCEXAMPLE" ,
16+ },
17+ ExpectedOutput : sdk.ProvisionOutput {
18+ Environment : map [string ]string {
19+ "LOCALSTACK_API_KEY" : "SzCEXAMPLE" ,
20+ },
21+ },
22+ },
23+ })
24+ }
25+
26+ func TestAPIKeyImporter (t * testing.T ) {
27+ plugintest .TestImporter (t , APIKey ().Importer , map [string ]plugintest.ImportCase {
28+ "environment" : {
29+ Environment : map [string ]string {
30+ "LOCALSTACK_API_KEY" : "SzCEXAMPLE" ,
31+ },
32+ ExpectedCandidates : []sdk.ImportCandidate {
33+ {
34+ Fields : map [sdk.FieldName ]string {
35+ fieldname .APIKey : "SzCEXAMPLE" ,
36+ },
37+ },
38+ },
39+ },
40+ })
41+ }
Original file line number Diff line number Diff line change 1+ package localstack
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 LocalStackCLI () schema.Executable {
11+ return schema.Executable {
12+ Name : "LocalStack CLI" ,
13+ Runs : []string {"localstack" },
14+ DocsURL : sdk .URL ("https://docs.localstack.cloud/getting-started/installation/#localstack-cli" ),
15+ NeedsAuth : needsauth .IfAll (
16+ needsauth .NotForHelpOrVersion (),
17+ needsauth .NotWithoutArgs (),
18+ ),
19+ Uses : []schema.CredentialUsage {
20+ {
21+ Name : credname .APIKey ,
22+ },
23+ },
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package localstack
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 : "localstack" ,
11+ Platform : schema.PlatformInfo {
12+ Name : "LocalStack" ,
13+ Homepage : sdk .URL ("https://localstack.cloud" ),
14+ },
15+ Credentials : []schema.CredentialType {
16+ APIKey (),
17+ },
18+ Executables : []schema.Executable {
19+ LocalStackCLI (),
20+ },
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments