|
| 1 | +package atlas |
| 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://www.mongodb.com/docs/atlas/configure-api-access/"), |
| 16 | + ManagementURL: nil, |
| 17 | + Fields: []schema.CredentialField{ |
| 18 | + { |
| 19 | + Name: fieldname.PublicKey, |
| 20 | + MarkdownDescription: "Public key used to authenticate to MongoDB Atlas.", |
| 21 | + Secret: false, |
| 22 | + Composition: &schema.ValueComposition{ |
| 23 | + Length: 8, |
| 24 | + Charset: schema.Charset{ |
| 25 | + Lowercase: true, |
| 26 | + }, |
| 27 | + }, |
| 28 | + }, |
| 29 | + { |
| 30 | + Name: fieldname.PrivateKey, |
| 31 | + MarkdownDescription: "Private key used to authenticate to MongoDB Atlas.", |
| 32 | + Secret: true, |
| 33 | + Composition: &schema.ValueComposition{ |
| 34 | + Length: 36, |
| 35 | + Charset: schema.Charset{ |
| 36 | + Lowercase: true, |
| 37 | + Digits: true, |
| 38 | + Specific: []rune{'-'}, |
| 39 | + }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + }, |
| 43 | + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), |
| 44 | + Importer: importer.TryAll( |
| 45 | + importer.TryEnvVarPair(defaultEnvVarMapping), |
| 46 | + )} |
| 47 | +} |
| 48 | + |
| 49 | +var defaultEnvVarMapping = map[string]sdk.FieldName{ |
| 50 | + "MONGODB_ATLAS_PUBLIC_API_KEY": fieldname.PublicKey, |
| 51 | + "MONGODB_ATLAS_PRIVATE_API_KEY": fieldname.PrivateKey, |
| 52 | +} |
0 commit comments