mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 15:38:06 +00:00
Update OpReadField method to be able to read different item fields
This commit is contained in:
@@ -6,6 +6,13 @@ import (
|
||||
"github.com/1Password/onepassword-operator/pkg/testhelper/system"
|
||||
)
|
||||
|
||||
type Field string
|
||||
|
||||
const (
|
||||
FieldUsername = "username"
|
||||
FieldPassword = "password"
|
||||
)
|
||||
|
||||
// UpdateItemPassword updates the password of an item in 1Password
|
||||
func UpdateItemPassword(item string) error {
|
||||
_, err := system.Run("op", "item", "edit", item, "--generate-password=letters,digits,symbols,32")
|
||||
@@ -15,9 +22,9 @@ func UpdateItemPassword(item string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadItemPassword reads the password of an item in 1Password
|
||||
func ReadItemPassword(item, vault string) (string, error) {
|
||||
output, err := system.Run("op", "read", fmt.Sprintf("op://%s/%s/password", vault, item))
|
||||
// ReadItemField reads the password of an item in 1Password
|
||||
func ReadItemField(item, vault string, field Field) (string, error) {
|
||||
output, err := system.Run("op", "read", fmt.Sprintf("op://%s/%s/%s", vault, item, field))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Reference in New Issue
Block a user