mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28: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"
|
"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
|
// UpdateItemPassword updates the password of an item in 1Password
|
||||||
func UpdateItemPassword(item string) error {
|
func UpdateItemPassword(item string) error {
|
||||||
_, err := system.Run("op", "item", "edit", item, "--generate-password=letters,digits,symbols,32")
|
_, err := system.Run("op", "item", "edit", item, "--generate-password=letters,digits,symbols,32")
|
||||||
@@ -15,9 +22,9 @@ func UpdateItemPassword(item string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadItemPassword reads the password of an item in 1Password
|
// ReadItemField reads the password of an item in 1Password
|
||||||
func ReadItemPassword(item, vault string) (string, error) {
|
func ReadItemField(item, vault string, field Field) (string, error) {
|
||||||
output, err := system.Run("op", "read", fmt.Sprintf("op://%s/%s/password", vault, item))
|
output, err := system.Run("op", "read", fmt.Sprintf("op://%s/%s/%s", vault, item, field))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user