From 72511ed68796cda7c756bf396973de700e1d9ee6 Mon Sep 17 00:00:00 2001 From: Volodymyr Zotov Date: Fri, 6 Jun 2025 12:56:17 -0500 Subject: [PATCH] Return error if both Connect and Service Account credentials are provided --- pkg/onepassword/client/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/onepassword/client/client.go b/pkg/onepassword/client/client.go index 89be108..1b0cd74 100644 --- a/pkg/onepassword/client/client.go +++ b/pkg/onepassword/client/client.go @@ -23,13 +23,19 @@ func NewClient(integrationVersion string) (Client, error) { connectToken, _ := os.LookupEnv("OP_CONNECT_TOKEN") serviceAccountToken, _ := os.LookupEnv("OP_SERVICE_ACCOUNT_TOKEN") + if connectHost != "" && connectToken != "" && serviceAccountToken != "" { + return nil, errors.New("invalid configuration. Either Connect or Service Account credentials should be set, not both") + } + if serviceAccountToken != "" { return sdk.NewClient(sdk.Config{ ServiceAccountToken: serviceAccountToken, IntegrationName: "1password-operator", IntegrationVersion: integrationVersion, }) - } else if connectHost != "" && connectToken != "" { + } + + if connectHost != "" && connectToken != "" { return connect.NewClient(connect.Config{ ConnectHost: connectHost, ConnectToken: connectToken,