mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28:06 +00:00
Return error if both Connect and Service Account credentials are provided
This commit is contained in:
@@ -23,13 +23,19 @@ func NewClient(integrationVersion string) (Client, error) {
|
|||||||
connectToken, _ := os.LookupEnv("OP_CONNECT_TOKEN")
|
connectToken, _ := os.LookupEnv("OP_CONNECT_TOKEN")
|
||||||
serviceAccountToken, _ := os.LookupEnv("OP_SERVICE_ACCOUNT_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 != "" {
|
if serviceAccountToken != "" {
|
||||||
return sdk.NewClient(sdk.Config{
|
return sdk.NewClient(sdk.Config{
|
||||||
ServiceAccountToken: serviceAccountToken,
|
ServiceAccountToken: serviceAccountToken,
|
||||||
IntegrationName: "1password-operator",
|
IntegrationName: "1password-operator",
|
||||||
IntegrationVersion: integrationVersion,
|
IntegrationVersion: integrationVersion,
|
||||||
})
|
})
|
||||||
} else if connectHost != "" && connectToken != "" {
|
}
|
||||||
|
|
||||||
|
if connectHost != "" && connectToken != "" {
|
||||||
return connect.NewClient(connect.Config{
|
return connect.NewClient(connect.Config{
|
||||||
ConnectHost: connectHost,
|
ConnectHost: connectHost,
|
||||||
ConnectToken: connectToken,
|
ConnectToken: connectToken,
|
||||||
|
Reference in New Issue
Block a user