Skip to content

Commit

Permalink
feat: check for OP_SERVICE_ACCOUNT_TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Feb 5, 2024
1 parent ec3024a commit ce9e507
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/template/onepassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ func isConnect() bool {
return os.Getenv("OP_CONNECT_HOST") != "" && os.Getenv("OP_CONNECT_TOKEN") != ""
}

func isServiceAccount() bool {
return os.Getenv("OP_SERVICE_ACCOUNT_TOKEN") != ""
}

func onePassword(ctx context.Context, templateVars interface{}, errorOnMissing bool) func(account, vaultUUID, itemUUID, field string) (string, error) {
if onePasswordCache == nil {
onePasswordCache = map[string]map[string]string{}
}
return func(account, vaultUUID, itemUUID, field string) (string, error) {
// validate command
if isConnect() {
if isConnect() || isServiceAccount() {
// do nothing
} else if _, err := exec.LookPath("op"); err != nil {
fmt.Println("Your templates includes a call to 1Password, please install it:")
Expand Down

0 comments on commit ce9e507

Please sign in to comment.