Introduce op package to handle op-cli commands

This commit is contained in:
Volodymyr Zotov
2025-08-22 09:38:21 -05:00
parent bb97134e10
commit 2b36f16940

24
pkg/testhelper/op/op.go Normal file
View File

@@ -0,0 +1,24 @@
package op
import (
"fmt"
"github.com/1Password/onepassword-operator/pkg/testhelper/system"
)
// 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")
if err != nil {
return err
}
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))
if err != nil {
return "", err
}
return output, nil
}