From 355920f143f8c44454b52c45691048b302433370 Mon Sep 17 00:00:00 2001 From: Maurizio Branca Date: Thu, 16 May 2024 16:36:21 +0200 Subject: [PATCH] Move remaining code out of eph.go --- x-pack/filebeat/input/azureeventhub/v1_eph.go | 36 +++++++++---------- .../filebeat/input/azureeventhub/v1_input.go | 20 +++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/x-pack/filebeat/input/azureeventhub/v1_eph.go b/x-pack/filebeat/input/azureeventhub/v1_eph.go index c771dbbb4635..bae2b465c6ef 100644 --- a/x-pack/filebeat/input/azureeventhub/v1_eph.go +++ b/x-pack/filebeat/input/azureeventhub/v1_eph.go @@ -6,8 +6,6 @@ package azureeventhub -import "github.com/Azure/go-autorest/autorest/azure" - // import ( // // "context" @@ -23,12 +21,12 @@ import "github.com/Azure/go-autorest/autorest/azure" // ) // // // users can select from one of the already defined azure cloud envs -var environments = map[string]azure.Environment{ - azure.ChinaCloud.ResourceManagerEndpoint: azure.ChinaCloud, - azure.GermanCloud.ResourceManagerEndpoint: azure.GermanCloud, - azure.PublicCloud.ResourceManagerEndpoint: azure.PublicCloud, - azure.USGovernmentCloud.ResourceManagerEndpoint: azure.USGovernmentCloud, -} +//var environments = map[string]azure.Environment{ +// azure.ChinaCloud.ResourceManagerEndpoint: azure.ChinaCloud, +// azure.GermanCloud.ResourceManagerEndpoint: azure.GermanCloud, +// azure.PublicCloud.ResourceManagerEndpoint: azure.PublicCloud, +// azure.USGovernmentCloud.ResourceManagerEndpoint: azure.USGovernmentCloud, +//} // // runWithEPH will consume ingested events using the Event Processor Host (EPH). // // @@ -105,14 +103,14 @@ var environments = map[string]azure.Environment{ // // return nil // } -func getAzureEnvironment(overrideResManager string) (azure.Environment, error) { - // if no override is set then the azure public cloud is used - if overrideResManager == "" || overrideResManager == "" { - return azure.PublicCloud, nil - } - if env, ok := environments[overrideResManager]; ok { - return env, nil - } - // can retrieve hybrid env from the resource manager endpoint - return azure.EnvironmentFromURL(overrideResManager) -} +//func getAzureEnvironment(overrideResManager string) (azure.Environment, error) { +// // if no override is set then the azure public cloud is used +// if overrideResManager == "" || overrideResManager == "" { +// return azure.PublicCloud, nil +// } +// if env, ok := environments[overrideResManager]; ok { +// return env, nil +// } +// // can retrieve hybrid env from the resource manager endpoint +// return azure.EnvironmentFromURL(overrideResManager) +//} diff --git a/x-pack/filebeat/input/azureeventhub/v1_input.go b/x-pack/filebeat/input/azureeventhub/v1_input.go index 4f0299d8040c..de52fc38e237 100644 --- a/x-pack/filebeat/input/azureeventhub/v1_input.go +++ b/x-pack/filebeat/input/azureeventhub/v1_input.go @@ -11,6 +11,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/Azure/go-autorest/autorest/azure" "time" eventhub "github.com/Azure/azure-event-hubs-go/v3" @@ -23,6 +24,13 @@ import ( "github.com/elastic/elastic-agent-libs/mapstr" ) +var environments = map[string]azure.Environment{ + azure.ChinaCloud.ResourceManagerEndpoint: azure.ChinaCloud, + azure.GermanCloud.ResourceManagerEndpoint: azure.GermanCloud, + azure.PublicCloud.ResourceManagerEndpoint: azure.PublicCloud, + azure.USGovernmentCloud.ResourceManagerEndpoint: azure.USGovernmentCloud, +} + type eventHubInputV1 struct { config azureInputConfig log *logp.Logger @@ -306,3 +314,15 @@ func (in *eventHubInputV1) parseMultipleRecords(bMessage []byte) []string { return messages } + +func getAzureEnvironment(overrideResManager string) (azure.Environment, error) { + // if no override is set then the azure public cloud is used + if overrideResManager == "" || overrideResManager == "" { + return azure.PublicCloud, nil + } + if env, ok := environments[overrideResManager]; ok { + return env, nil + } + // can retrieve hybrid env from the resource manager endpoint + return azure.EnvironmentFromURL(overrideResManager) +}