Skip to content

Commit

Permalink
refactor eventhub checkpointStrategy parameter values to lowercase
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Leinweber <[email protected]>
  • Loading branch information
christle committed May 3, 2021
1 parent 392a36e commit 0822640
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions pkg/scalers/azure/azure_eventhub_checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kedacore/keda/v2/pkg/util"
)

// goCheckpoint struct to adapt GoSdk Checkpoint
// goCheckpoint struct to adapt goSdk Checkpoint
type goCheckpoint struct {
Checkpoint struct {
SequenceNumber int64 `json:"sequenceNumber"`
Expand Down Expand Up @@ -78,17 +78,17 @@ func GetCheckpointFromBlobStorage(ctx context.Context, httpClient util.HTTPDoer,

func newCheckpointer(info EventHubInfo, partitionID string) checkpointer {
switch {
case (info.CheckpointStrategy == "GoSdk"):
case (info.CheckpointStrategy == "goSdk"):
return &goSdkCheckpointer{
containerName: info.BlobContainer,
partitionID: partitionID,
}
case (info.CheckpointStrategy == "BlobMetadata"):
case (info.CheckpointStrategy == "blobMetadata"):
return &blobMetadataCheckpointer{
containerName: info.BlobContainer,
partitionID: partitionID,
}
case (info.CheckpointStrategy == "AzureWebJob" || info.BlobContainer == ""):
case (info.CheckpointStrategy == "azureWebJob" || info.BlobContainer == ""):
return &azureWebjobCheckpointer{
containerName: "azure-webjobs-eventhub",
partitionID: partitionID,
Expand Down Expand Up @@ -124,7 +124,7 @@ func (checkpointer *azureWebjobCheckpointer) extractCheckpoint(get *azblob.Downl
return checkpoint, nil
}

// resolve path for BlobMetadataCheckpointer
// resolve path for blobMetadataCheckpointer
func (checkpointer *blobMetadataCheckpointer) resolvePath(info EventHubInfo) (*url.URL, error) {
eventHubNamespace, eventHubName, err := getHubAndNamespace(info)
if err != nil {
Expand All @@ -135,19 +135,19 @@ func (checkpointer *blobMetadataCheckpointer) resolvePath(info EventHubInfo) (*u
return path, nil
}

// extract checkpoint for BlobMetadataCheckpointer
// extract checkpoint for blobMetadataCheckpointer
func (checkpointer *blobMetadataCheckpointer) extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) {
return getCheckpointFromStorageMetadata(get, checkpointer.partitionID)
}

// resolve path for GoSdkCheckpointer
// resolve path for goSdkCheckpointer
func (checkpointer *goSdkCheckpointer) resolvePath(info EventHubInfo) (*url.URL, error) {
path, _ := url.Parse(fmt.Sprintf("/%s/%s", info.BlobContainer, checkpointer.partitionID))

return path, nil
}

// extract checkpoint for GoSdkCheckpointer
// extract checkpoint for goSdkCheckpointer
func (checkpointer *goSdkCheckpointer) extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) {
var checkpoint goCheckpoint
err := readToCheckpointFromBody(get, &checkpoint)
Expand Down
10 changes: 5 additions & 5 deletions pkg/scalers/azure/azure_eventhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestCheckpointFromBlobStorageWithBlobMetadata(t *testing.T) {
EventHubConsumerGroup: consumerGroup,
EventHubName: "hub",
BlobContainer: containerName,
CheckpointStrategy: "BlobMetadata",
CheckpointStrategy: "blobMetadata",
}

check, _ := GetCheckpointFromBlobStorage(ctx, http.DefaultClient, eventHubInfo, partitionID)
Expand Down Expand Up @@ -216,7 +216,7 @@ func TestCheckpointFromBlobStorageGoSdk(t *testing.T) {
StorageConnection: StorageConnectionString,
EventHubName: "hub",
BlobContainer: containerName,
CheckpointStrategy: "GoSdk",
CheckpointStrategy: "goSdk",
}

check, _ := GetCheckpointFromBlobStorage(ctx, http.DefaultClient, eventHubInfo, partitionID)
Expand All @@ -241,7 +241,7 @@ func TestShouldParseCheckpointForWebJobWithCheckpointStrategy(t *testing.T) {
eventHubInfo := EventHubInfo{
EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test",
EventHubConsumerGroup: "$Default",
CheckpointStrategy: "AzureWebJob",
CheckpointStrategy: "azureWebJob",
}

cp := newCheckpointer(eventHubInfo, "0")
Expand All @@ -268,7 +268,7 @@ func TestShouldParseCheckpointForBlobMetadata(t *testing.T) {
EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test",
EventHubConsumerGroup: "$Default",
BlobContainer: "containername",
CheckpointStrategy: "BlobMetadata",
CheckpointStrategy: "blobMetadata",
}

cp := newCheckpointer(eventHubInfo, "0")
Expand All @@ -282,7 +282,7 @@ func TestShouldParseCheckpointForGoSdk(t *testing.T) {
EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test",
EventHubConsumerGroup: "$Default",
BlobContainer: "containername",
CheckpointStrategy: "GoSdk",
CheckpointStrategy: "goSdk",
}

cp := newCheckpointer(eventHubInfo, "0")
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/azure_eventhub_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var parseEventHubMetadataDataset = []parseEventHubMetadataTestData{
// missing unprocessed event threshold - should replace with default
{map[string]string{"storageConnectionFromEnv": storageConnectionSetting, "consumerGroup": eventHubConsumerGroup, "connectionFromEnv": eventHubConnectionSetting}, false},
// added blob container details
{map[string]string{"storageConnectionFromEnv": storageConnectionSetting, "consumerGroup": eventHubConsumerGroup, "connectionFromEnv": eventHubConnectionSetting, "blobContainer": testContainerName, "checkpointStrategy": "AzureWebJob"}, false},
{map[string]string{"storageConnectionFromEnv": storageConnectionSetting, "consumerGroup": eventHubConsumerGroup, "connectionFromEnv": eventHubConnectionSetting, "blobContainer": testContainerName, "checkpointStrategy": "azureWebJob"}, false},
}

var parseEventHubMetadataDatasetWithPodIdentity = []parseEventHubMetadataTestData{
Expand Down

0 comments on commit 0822640

Please sign in to comment.