Skip to content

Commit

Permalink
Throw error if EH credential env vars aren't present
Browse files Browse the repository at this point in the history
  • Loading branch information
colmsnowplow committed Jul 21, 2021
1 parent 3397d93 commit 99b6055
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/target/eventhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package target
import (
"context"
"fmt"
"os"
"time"

eventhub "github.com/Azure/azure-event-hubs-go/v3"
Expand Down Expand Up @@ -50,6 +51,12 @@ type EventHubTarget struct {
// NewEventHubTarget creates a new client for writing messages to Azure EventHub
func NewEventHubTarget(cfg *EventHubConfig) (*EventHubTarget, error) {

keyName, keyNamePresent := os.LookupEnv("EVENTHUB_KEY_NAME")
keyValue, keyValuePresent := os.LookupEnv("EVENTHUB_KEY_VALUE")
if !(keyNamePresent && keyValuePresent) {
return nil, errors.Errorf("Error initialising EventHub client: Env vars %s and %s are required for authentication.", keyName, keyValue)
}

hub, err := eventhub.NewHubWithNamespaceNameAndEnvironment(cfg.EventHubNamespace, cfg.EventHubName)

return &EventHubTarget{
Expand Down

0 comments on commit 99b6055

Please sign in to comment.