Skip to content

Commit

Permalink
Handle Connect configuration and No configuration is separate if-else…
Browse files Browse the repository at this point in the history
… case
  • Loading branch information
volodymyrZotov committed Nov 21, 2023
1 parent 9646ad3 commit d932e47
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions onepassword/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d932e47

Please sign in to comment.