From 36b11966f812bb154d9d2fcd67bb93cee7583ed5 Mon Sep 17 00:00:00 2001 From: Christian Leinweber Date: Tue, 4 May 2021 09:01:21 +0200 Subject: [PATCH] rename eventhub checkpointStrategy parameter azureWebJob to azureFunction Signed-off-by: Christian Leinweber --- pkg/scalers/azure/azure_eventhub_checkpoint.go | 14 +++++++------- pkg/scalers/azure/azure_eventhub_test.go | 8 ++++---- pkg/scalers/azure_eventhub_scaler_test.go | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/scalers/azure/azure_eventhub_checkpoint.go b/pkg/scalers/azure/azure_eventhub_checkpoint.go index 64babfacd69..ac43ae80ceb 100644 --- a/pkg/scalers/azure/azure_eventhub_checkpoint.go +++ b/pkg/scalers/azure/azure_eventhub_checkpoint.go @@ -50,7 +50,7 @@ type checkpointer interface { extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) } -type azureWebjobCheckpointer struct { +type azureFunctionCheckpointer struct { partitionID string containerName string } @@ -88,8 +88,8 @@ func newCheckpointer(info EventHubInfo, partitionID string) checkpointer { containerName: info.BlobContainer, partitionID: partitionID, } - case (info.CheckpointStrategy == "azureWebJob" || info.BlobContainer == ""): - return &azureWebjobCheckpointer{ + case (info.CheckpointStrategy == "azureFunction" || info.BlobContainer == ""): + return &azureFunctionCheckpointer{ containerName: "azure-webjobs-eventhub", partitionID: partitionID, } @@ -101,8 +101,8 @@ func newCheckpointer(info EventHubInfo, partitionID string) checkpointer { } } -// resolve path for AzureWebJobCheckpointer -func (checkpointer *azureWebjobCheckpointer) resolvePath(info EventHubInfo) (*url.URL, error) { +// resolve path for AzureFunctionCheckpointer +func (checkpointer *azureFunctionCheckpointer) resolvePath(info EventHubInfo) (*url.URL, error) { eventHubNamespace, eventHubName, err := getHubAndNamespace(info) if err != nil { return nil, err @@ -113,8 +113,8 @@ func (checkpointer *azureWebjobCheckpointer) resolvePath(info EventHubInfo) (*ur return path, nil } -// extract checkpoint for AzureWebJobCheckpointer -func (checkpointer *azureWebjobCheckpointer) extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) { +// extract checkpoint for AzureFunctionCheckpointer +func (checkpointer *azureFunctionCheckpointer) extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) { var checkpoint Checkpoint err := readToCheckpointFromBody(get, &checkpoint) if err != nil { diff --git a/pkg/scalers/azure/azure_eventhub_test.go b/pkg/scalers/azure/azure_eventhub_test.go index fe7ec2a8bf6..06f7a5a116b 100644 --- a/pkg/scalers/azure/azure_eventhub_test.go +++ b/pkg/scalers/azure/azure_eventhub_test.go @@ -17,7 +17,7 @@ import ( // Add a valid Storage account connection string here const StorageConnectionString = "" -func TestCheckpointFromBlobStorageAzureWebjob(t *testing.T) { +func TestCheckpointFromBlobStorageAzureFunction(t *testing.T) { if StorageConnectionString == "" { return } @@ -225,7 +225,7 @@ func TestCheckpointFromBlobStorageGoSdk(t *testing.T) { assert.Equal(t, check, expectedCheckpoint) } -func TestShouldParseCheckpointForWebJob(t *testing.T) { +func TestShouldParseCheckpointForFunction(t *testing.T) { eventHubInfo := EventHubInfo{ EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test", EventHubConsumerGroup: "$Default", @@ -237,11 +237,11 @@ func TestShouldParseCheckpointForWebJob(t *testing.T) { assert.Equal(t, url.Path, "/azure-webjobs-eventhub/eventhubnamespace.servicebus.windows.net/hub-test/$Default/0") } -func TestShouldParseCheckpointForWebJobWithCheckpointStrategy(t *testing.T) { +func TestShouldParseCheckpointForFunctionWithCheckpointStrategy(t *testing.T) { eventHubInfo := EventHubInfo{ EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test", EventHubConsumerGroup: "$Default", - CheckpointStrategy: "azureWebJob", + CheckpointStrategy: "azureFunction", } cp := newCheckpointer(eventHubInfo, "0") diff --git a/pkg/scalers/azure_eventhub_scaler_test.go b/pkg/scalers/azure_eventhub_scaler_test.go index 07e892feebf..0565f7e2462 100644 --- a/pkg/scalers/azure_eventhub_scaler_test.go +++ b/pkg/scalers/azure_eventhub_scaler_test.go @@ -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": "azureFunction"}, false}, } var parseEventHubMetadataDatasetWithPodIdentity = []parseEventHubMetadataTestData{