Skip to content

Commit

Permalink
Use constants in our list of accepted values
Browse files Browse the repository at this point in the history
Use the constants we have already defined from the Connect SDK (apply to both Connect and CLI clients) to be more consistent and reduce amount of magic strings used in our codebase.
  • Loading branch information
edif2008 committed Apr 24, 2024
1 parent 025fc20 commit 032e2fd
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions internal/provider/const.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package provider

import (
"strings"

op "github.com/1Password/connect-sdk-go/onepassword"
)

const (
terraformItemIDDescription = "The Terraform resource identifier for this item in the format `vaults/<vault_id>/items/<item_id>`."

Expand Down Expand Up @@ -44,8 +50,29 @@ const (
)

var (
categories = []string{"login", "password", "database"}
dbTypes = []string{"db2", "filemaker", "msaccess", "mssql", "mysql", "oracle", "postgresql", "sqlite", "other"}
fieldPurposes = []string{"USERNAME", "PASSWORD", "NOTES"}
fieldTypes = []string{"STRING", "EMAIL", "CONCEALED", "URL", "OTP", "DATE", "MONTH_YEAR", "MENU", "PHONE"}
dbTypes = []string{"db2", "filemaker", "msaccess", "mssql", "mysql", "oracle", "postgresql", "sqlite", "other"}

categories = []string{
strings.ToLower(string(op.Login)),
strings.ToLower(string(op.Password)),
strings.ToLower(string(op.Database)),
}

fieldPurposes = []string{
string(op.FieldPurposeUsername),
string(op.FieldPurposePassword),
string(op.FieldPurposeNotes),
}

fieldTypes = []string{
string(op.FieldTypeString),
string(op.FieldTypeConcealed),
string(op.FieldTypeEmail),
string(op.FieldTypeURL),
string(op.FieldTypeOTP),
string(op.FieldTypeDate),
string(op.FieldTypeMonthYear),
string(op.FieldTypeMenu),
string(op.FieldTypePhone),
}
)

0 comments on commit 032e2fd

Please sign in to comment.