-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config option to select a different azure cloud env in the azure-eventhub input and azure module #17659
Merged
Merged
Add config option to select a different azure cloud env in the azure-eventhub input and azure module #17659
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2d3aa03
add option to select a different azure env
narph f1dc7da
changelog
narph 33dd8f3
rename
narph 2fafce9
add test
narph 4bbd313
Merge branch 'master' into add-other-env
narph c244182
mage fmt update
narph 7f0414a
Merge branch 'master' into add-other-env
narph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,26 @@ 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, | ||
} | ||
|
||
// runWithEPH will consume ingested events using the Event Processor Host (EPH) https://github.com/Azure/azure-event-hubs-go#event-processor-host, https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-event-processor-host | ||
func (a *azureInput) runWithEPH() error { | ||
// create a new Azure Storage Leaser / Checkpointer | ||
cred, err := azblob.NewSharedKeyCredential(a.config.SAName, a.config.SAKey) | ||
if err != nil { | ||
return err | ||
} | ||
leaserCheckpointer, err := storage.NewStorageLeaserCheckpointer(cred, a.config.SAName, a.config.SAContainer, azure.PublicCloud) | ||
env, err := getAzureEnvironment(a.config.OverrideEnvironment) | ||
if err != nil { | ||
return err | ||
} | ||
leaserCheckpointer, err := storage.NewStorageLeaserCheckpointer(cred, a.config.SAName, a.config.SAContainer, env) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -74,3 +86,15 @@ func (a *azureInput) runWithEPH() error { | |
} | ||
return nil | ||
} | ||
|
||
func getAzureEnvironment(overrideResManager string) (azure.Environment, error) { | ||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// if no overrride is set then the azure public cloud is used | ||
if overrideResManager == "" { | ||
return azure.PublicCloud, nil | ||
} | ||
if env, ok := environments[overrideResManager]; ok { | ||
return env, nil | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit. Should we try without the |
||
// can retrieve hybrid env from the resource manager endpoint | ||
return azure.EnvironmentFromURL(overrideResManager) | ||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the comments by Blake and Kaiyan, don't consider this an override, just a normal setting. Add also something about possible values. And possibly something about hybrid clouds support.
Maybe we could add an explicit option for environment URLs, instead of accepting names and urls in the same option. And maybe use something like
environment
instead ofresource_manager_endpoint
, in case we use the same settings for features that need access to other endpoints.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsoriano , the reason I went for the
override-
is because I do not want users to necessary specify this setting, this should be only used for other private env. To look for the azure resource manager endpoint might take some effort for the users and I want to avoid that in most of the cases where the are using the public cloud.One workaround I would go for is to rename this option to
resource_manager_endpoint
but not add it in the config files so users will not be tempted to enter it if unnecessary.Not sure what you mean by " instead of accepting names and urls in the same option" , we only accept azure resource manager endpoints, the azure-eventhub sdk can retrieve the specific environment based on that.
Also adding
environment.name
andenvironment.url
might cause more confusion as users will have a hard time figuring those out, also there is noenvironment.url
, we can talk aboutmanagement_portal_URL
orresource_manager_endpoint
orservice_endpoint
but with theresource_manager_endpoint
the SDK can help us identify the right env.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other optional settings behave the same way, and don't have an
override
prefix, would it be different to other optional settings?Yes, I find perfectly fine to have this option in the reference docs, but not in the config files.
Oh, ok, my mistake then, I saw that we accept URLs, and I thought we also accepted some kind of identifier there. One more reason to add some example values in the docs 🙂
I have still a question about that, the URLs accepted by
EnvironmentFromURL
, are of the same kind as the ones of the resource manager endpoints?I was suggesting that to make configuration and its documentation easier. A user wanting to use the US Gov cloud would use
environment.name: usgov
, or something similar, accepted values could be in the documentation, so they don't need to look for specific endpoints in other places. A user that is using a hybrid cloud would useenvironment.url: http://....
with an URL that can be accepted byEnvironmentFromURL
.Something like this would be specially helpful if we need to use at some point other endpoints, e.g: the Service Manager Endpoint, so we don't have to add a setting like
service_manager_endpoint
.But I don't know much about these endpoints and URLs, so as you prefer 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I answer myself after reading
EnvironmentFromURL
source. It seems that the URL accepted by this method is actually the resource manager endpoints and from that it obtains the other endpoints, so this solves my concerns about having different kind of values for hybrid clouds.So I think that the only pending things to consider would be:
resource_manager_endpoint
.