mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28:06 +00:00
Add more logs and fix params order
This commit is contained in:
@@ -2,6 +2,7 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/1Password/onepassword-operator/pkg/onepassword/client/connect"
|
"github.com/1Password/onepassword-operator/pkg/onepassword/client/connect"
|
||||||
@@ -28,6 +29,7 @@ func NewClient(integrationVersion string) (Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if serviceAccountToken != "" {
|
if serviceAccountToken != "" {
|
||||||
|
fmt.Printf("Using Service Account Token")
|
||||||
return sdk.NewClient(sdk.Config{
|
return sdk.NewClient(sdk.Config{
|
||||||
ServiceAccountToken: serviceAccountToken,
|
ServiceAccountToken: serviceAccountToken,
|
||||||
IntegrationName: "1password-operator",
|
IntegrationName: "1password-operator",
|
||||||
@@ -36,6 +38,7 @@ func NewClient(integrationVersion string) (Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if connectHost != "" && connectToken != "" {
|
if connectHost != "" && connectToken != "" {
|
||||||
|
fmt.Printf("Using Connect")
|
||||||
return connect.NewClient(connect.Config{
|
return connect.NewClient(connect.Config{
|
||||||
ConnectHost: connectHost,
|
ConnectHost: connectHost,
|
||||||
ConnectToken: connectToken,
|
ConnectToken: connectToken,
|
||||||
|
@@ -19,17 +19,17 @@ func GetOnePasswordItemByPath(opClient opclient.Client, path string) (*model.Ite
|
|||||||
}
|
}
|
||||||
vaultID, err := getVaultID(opClient, vaultIdentifier)
|
vaultID, err := getVaultID(opClient, vaultIdentifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to 'getVaultID' for vaultIdentifier='%s': %w", vaultIdentifier, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemID, err := getItemID(opClient, vaultID, itemIdentifier)
|
itemID, err := getItemID(opClient, vaultID, itemIdentifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("faild to 'getItemID' for vaultID='%s' and itemIdentifier='%s': %w", vaultID, itemIdentifier, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
item, err := opClient.GetItemByID(itemID, vaultID)
|
item, err := opClient.GetItemByID(vaultID, itemID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("faield to 'GetItemByID' for vaultID='%s' and itemID='%s': %w", vaultID, itemID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range item.Files {
|
for _, file := range item.Files {
|
||||||
@@ -77,7 +77,7 @@ func getVaultID(client opclient.Client, vaultIdentifier string) (string, error)
|
|||||||
|
|
||||||
func getItemID(client opclient.Client, vaultId, itemIdentifier string) (string, error) {
|
func getItemID(client opclient.Client, vaultId, itemIdentifier string) (string, error) {
|
||||||
if !IsValidClientUUID(itemIdentifier) {
|
if !IsValidClientUUID(itemIdentifier) {
|
||||||
items, err := client.GetItemsByTitle(itemIdentifier, vaultId)
|
items, err := client.GetItemsByTitle(vaultId, itemIdentifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user