diff --git a/pkg/testhelper/op/op.go b/pkg/testhelper/op/op.go index 658cf21..cb25fb1 100644 --- a/pkg/testhelper/op/op.go +++ b/pkg/testhelper/op/op.go @@ -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 }