Skip to content

Commit

Permalink
Move remaining code out of eph.go
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoog committed May 16, 2024
1 parent 19d1356 commit 355920f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
36 changes: 17 additions & 19 deletions x-pack/filebeat/input/azureeventhub/v1_eph.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package azureeventhub

import "github.com/Azure/go-autorest/autorest/azure"

// import (
//
// "context"
Expand All @@ -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).
// //
Expand Down Expand Up @@ -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 == "<no value>" {
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 == "<no value>" {
// 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)
//}
20 changes: 20 additions & 0 deletions x-pack/filebeat/input/azureeventhub/v1_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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 == "<no value>" {
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)
}

0 comments on commit 355920f

Please sign in to comment.