From d932e47eeee9673a94dace786d1ab80d52e65353 Mon Sep 17 00:00:00 2001 From: Volodymyr Zotov Date: Tue, 21 Nov 2023 16:57:47 -0600 Subject: [PATCH] Handle Connect configuration and No configuration is separate if-else case --- onepassword/provider.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/onepassword/provider.go b/onepassword/provider.go index 3b036265..af4595d7 100644 --- a/onepassword/provider.go +++ b/onepassword/provider.go @@ -105,16 +105,11 @@ func Provider() *schema.Provider { } return (Client)(op), nil + } else if token != "" && url != "" { + return connectctx.Wrap(connect.NewClientWithUserAgent(url, token, providerUserAgent)), nil + } else { + return nil, diag.Errorf("Invalid provider configuration. Either Connect credentials (\"token\" and \"url\") or Service Account (\"service_account_token\") credentials should be set.") } - - if token == "" { - return nil, diag.Errorf("Connect Token is not set. Either provide the \"token\" field in the provider configuration or set the \"OP_CONNECT_TOKEN\" environment variable.") - } - if url == "" { - return nil, diag.Errorf("Connect URL is not set. Either provide the \"url\" field in the provider configuration or set the \"OP_CONNECT_HOST\" environment variable.") - } - - return connectctx.Wrap(connect.NewClientWithUserAgent(url, token, providerUserAgent)), nil } return provider }