Merge branch 'master' into release203

This commit is contained in:
David Justice 2019-10-03 09:56:46 -07:00 коммит произвёл GitHub
Родитель a984ddad53 a106c43ebe
Коммит fbb9569424
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 105 добавлений и 79 удалений

Просмотреть файл

@ -1,36 +1,36 @@
language: go
sudo: false
go:
- 1.x
- 1.11.x
- 1.x
- 1.11.x
before_install:
- cd ${TRAVIS_HOME}
- export GO111MODULE=auto
- go get -u github.com/mattn/goveralls
- go get -u golang.org/x/tools/cmd/cover
- go get -u github.com/fzipp/gocyclo
- go get -u golang.org/x/lint/golint
- cd ${TRAVIS_BUILD_DIR}
- cd ${TRAVIS_HOME}
- export GO111MODULE=auto
- go get -u github.com/mattn/goveralls
- go get -u golang.org/x/tools/cmd/cover
- go get -u github.com/fzipp/gocyclo
- go get -u golang.org/x/lint/golint
- cd ${TRAVIS_BUILD_DIR}
jobs:
include:
- stage: integration tests
if: type IN (push, cron)
env:
- TF_VAR_resource_group_name=eh-travis
- secure: IWLgsNBMMDBjJSLRixla9jqiTm3xeERnPiECt+PdjUH3ZevyLOR1tX1Q2V6WS9afFsoddM5QpvqXF50UpNzD2WwnE492syL4x0rHfMhV4aZcN82zrMuggYAenLINfBYcryciGgTtPK767vdU3sbqNl7Nkz0lGd/SYqvgCCd9djMZfG5OccuMm1m/v7VCf0BwJgbk6wH0+J+YocFPpROkvIfPiclJIB+o1ejp8odYsbV2ZO144i7AM18oeEt13iBKz8kIXEf2/xZZ7nZu33VYqpp9K7gRc83ORDZSaKBb+SwtnnaXBrcAKayeJCfsumkPh94eFFqogfOiC2iZg07B1ojQir+n2bgPpBO6Fa4G+A1i7sVotYTmzmBNX7I8K4+0F5U96srtrFWHO13X/2OKxTNRBv2w6rf5Sz8AD7mnuLhAHxXTXdlYAiQ8CaKpUIPhzJBF9A/Ax3fPbSLAvUBGcP/9uTV3NvGQynVaSF0D4DzI3X3hRjuTso14b0EYY5wuB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y+38JKd3c7Eykx5Lrg8pDlsuE+b5xJaPV3sGFgktI1dPH4obk7RWKTqvEN/IyFwhOsdcJE=
script:
- curl -sLo /tmp/terraform.zip https://releases.hashicorp.com/terraform/0.11.10/terraform_0.11.10_linux_amd64.zip
- unzip /tmp/terraform.zip -d /tmp
- mkdir -p ~/bin
- mv /tmp/terraform ~/bin
- export PATH="~/bin:$PATH"
- export GO111MODULE=on
- make test-cover
- goveralls -coverprofile=cover.out -service=travis-ci
- make destroy
- stage: integration tests
if: type IN (push, cron)
env:
- TF_VAR_resource_group_name=eh-travis
- secure: Gytv/BG8PzkBU845teKJdci1RbYzuHn4slhYIQEEZ8r0hvb57YtPD1NUBLWzndj3qrmhJceRkDyKd3gfAIrvLFEp0rD+4E5S2lTjOST4OZRaN8HKKA8dtc1PYlcF1Hr4wA4rx69oKVBncdQYZXE2Sdnx3QwuWnT1G2B3PYvnb1Ess16/4Z4PDZL4Jp2KTubV5nZd70zBJzEkaem4FE/x8pAqKsaNLNuabYRjywzNwcrKqUAYuiy1BaYD/XxKDQ/dNfGEK3gXitNqWqNURghGBlE3e0x++mwIWvW3b8wP+JyvUv3vM6FS7+Rw8qz8XhaG820Sqs8eM4GUxX9BttOOR5KpzbBYH0KgygE3Axo5saktpqImBB0gKi2fNqT7YvdU+peMLIVipsxPHdO0CEgvgFPLIkMdpaXYyjQJWNDDukcRpu+/LVCQRb5Fh8jTS1z8U59sdgW3Ld5YVw6Jt0vO4mNfA799o7yzWlO3a5ZLJotQtXm6WCwOq7IE5m3ObQYbi1YWAlBXuTuHPk4fCSTQJDUkFi4jDSnN4xqlItk+URilyAt+Vs5OuRAztfM/o4/TEjdkXx0T/veZ3eibksdSnYAgHQPCQ6MqeWAk4AKrIJysPQuyPhNo2ye5jh/aozL6VYE9dcft3+RAwp6jQAtP/pv8SpsTkWuC7LnSeJvMa6c=
- secure: eVK61SdkKa+KeIs7iJ0tCWnVlj/BSdc6Yepk42chtRdmikzaXSSvyoRplKJoFutpkSLd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/QoXEaHOGiOVsE9/UUYmpYQZYbdnkzBiEF7oPkoxTNjuzdYt2SQLvQeOah4qkHy3oH83c8EcU+aPMEWCc3yTkqY75VATyIa/TP3rySAFcogq/Kd4aDUWwcxO4u1B2TD8UNE5YqftWo97Heo6lE+kAr1FfhxS6cwuWMTfQ5KwgFv+Qlgb71zlP3T/Yn5kPdGY0kwoqiEmq5hjcjOHLLYYvBsYPfAmtQMKSe2fFZ53Q=
- secure: SPYzI+Fyzbf0blXoX7vSCWcgPfTQnkNy1jSNps68a0dy1yE3WAc/AEgV4wcwgFjV7WkMIX9ik0q5ggbiVgMw1nQA4U6K8n7yJsqI+s0GGEdE1Y1HBCWIMJw1JazTHI2qRg69UiVj2xI1LPvTFGgxClGnZoPCh9dxlMPO6M2f90mJUKVNxkjuLe1BWnLyzyGZnhB/EEam39ijOVnkfXdwcN4nGUjMsEwi5rOQLeZsymgKqN2aMeXtZltTeertO4ob8K2hGinNHjkYzjyFSCZvGaubnVr22F777YDCvh0cq7CTRQiMm1KiHT9QZ/0JbvsfC+0TPl0lXnLx6NnMvlKL5sA6xpFcarO4nGB4jON5SnVPF+3VW0BSyfypFHAn/fSSmftqg8TI7uSGuOJauG2ld/1e1v9WPkY56frC2ULVWt7eZFOpIm9JoosCjKgwQjx320VwJgKW8xJ4ynAPqFVVlZCdQEs+NJGOOJi1NkDpd++QolgKFkPdkBNFmVYRPdVe/iRzaipZ2WOX94sg+5CfA5TcZTz2fvDJHyNgqEkVUS9VHWDB75nkJ8vq1b8G9+wM/ulAsdepjaPlatd0pGeVJzt1IwJFDUgddCEXHub0HXuJk2kE7V/i1h0E4kcfQq8HFEJaG1tsWe2kA+OBX58pCZWXmDB2KshGWW9tlWzwRlo=
script:
- curl -sLo /tmp/terraform.zip https://releases.hashicorp.com/terraform/0.12.8/terraform_0.12.8_linux_amd64.zip
- unzip /tmp/terraform.zip -d /tmp
- mkdir -p ~/bin
- mv /tmp/terraform ~/bin
- export PATH="~/bin:$PATH"
- export GO111MODULE=on
- make test-cover
- goveralls -coverprofile=cover.out -service=travis-ci
- make destroy
script:
- export GO111MODULE=on
- make
- export GO111MODULE=on
- make

Просмотреть файл

@ -66,7 +66,7 @@ cyclo: ; $(info $(M) running gocyclo...) @ ## Run gocyclo on all source files
terraform.tfstate: azuredeploy.tf $(wildcard terraform.tfvars) .terraform ; $(info $(M) running terraform...) @ ## Run terraform to provision infrastructure needed for testing
$Q TF_VAR_azure_client_secret="$${ARM_CLIENT_SECRET}" terraform apply -auto-approve
$Q terraform output > .env
$Q terraform output -json | jq -r 'keys[] as $$k | "\($$k) = \(.[$$k].value)"' > .env
.terraform:
$Q terraform init

Просмотреть файл

@ -1,8 +1,20 @@
provider "azuread" {
version = "~> 0.6"
}
provider "azurerm" {
version = "~> 1.34"
}
provider "random" {
version = "~> 2.2"
}
variable "location" {
# eastus support AAD authentication, which at the time of writing this is in preview.
# see: https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-role-based-access-control
description = "Azure datacenter to deploy to."
default = "eastus"
description = "Azure datacenter to deploy to."
default = "eastus"
}
variable "eventhub_name_prefix" {
@ -21,7 +33,8 @@ variable "azure_client_secret" {
}
# Data resources used to get SubID and Tennant Info
data "azurerm_client_config" "current" {}
data "azurerm_client_config" "current" {
}
resource "random_string" "name" {
length = 8
@ -32,29 +45,29 @@ resource "random_string" "name" {
# Create resource group for all of the things
resource "azurerm_resource_group" "test" {
name = "${var.resource_group_name_prefix}-${random_string.name.result}"
location = "${var.location}"
name = "${var.resource_group_name_prefix}-${random_string.name.result}"
location = var.location
}
# Create an Event Hub namespace for testing
resource "azurerm_eventhub_namespace" "test" {
name = "${var.eventhub_name_prefix}-${random_string.name.result}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "standard"
}
resource "azurerm_storage_account" "test" {
name = "${var.eventhub_name_prefix}${random_string.name.result}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
account_replication_type = "LRS"
account_tier = "Standard"
name = "${var.eventhub_name_prefix}${random_string.name.result}"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_replication_type = "LRS"
account_tier = "Standard"
}
# Generate a random secret fo the service principal
resource "random_string" "secret" {
count = "${data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0}"
count = data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0
length = 32
upper = true
special = true
@ -62,48 +75,48 @@ resource "random_string" "secret" {
}
// Application for AAD authentication
resource "azurerm_azuread_application" "test" {
count = "${data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0}"
name = "eventhubstest"
homepage = "https://eventhubstest"
identifier_uris = ["https://eventhubstest"]
reply_urls = ["https://eventhubstest"]
available_to_other_tenants = false
oauth2_allow_implicit_flow = true
resource "azuread_application" "test" {
count = data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0
name = "eventhubstest"
homepage = "https://eventhubstest"
identifier_uris = ["https://eventhubstest"]
reply_urls = ["https://eventhubstest"]
available_to_other_tenants = false
oauth2_allow_implicit_flow = true
}
# Create a service principal, which represents a linkage between the AAD application and the password
resource "azurerm_azuread_service_principal" "test" {
count = "${data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0}"
application_id = "${azurerm_azuread_application.test.application_id}"
resource "azuread_service_principal" "test" {
count = data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0
application_id = azuread_application.test[0].application_id
}
# Create a new service principal password which will be the AZURE_CLIENT_SECRET env var
resource "azurerm_azuread_service_principal_password" "test" {
count = "${data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0}"
service_principal_id = "${azurerm_azuread_service_principal.test.id}"
value = "${random_string.secret.result}"
end_date = "2030-01-01T01:02:03Z"
}
# This provides the new AAD application the rights to managed, send and receive from the Event Hubs instance
resource "azurerm_role_assignment" "service_principal_eh" {
count = "${data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0}"
scope = "subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.test.name}/providers/Microsoft.EventHub/namespaces/${azurerm_eventhub_namespace.test.name}"
role_definition_name = "Owner"
principal_id = "${azurerm_azuread_service_principal.test.id}"
resource "azuread_service_principal_password" "test" {
count = data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0
service_principal_id = azuread_service_principal.test[0].id
value = random_string.secret[0].result
end_date = "2030-01-01T01:02:03Z"
}
# This provides the new AAD application the rights to managed the resource group
resource "azurerm_role_assignment" "service_principal_rg" {
count = "${data.azurerm_client_config.current.service_principal_application_id == "" ? 1 : 0}"
scope = "subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.test.name}"
role_definition_name = "Owner"
principal_id = "${azurerm_azuread_service_principal.test.id}"
scope = "subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.test.name}"
role_definition_name = "Owner"
principal_id = data.azurerm_client_config.current.service_principal_application_id == "" ? azuread_service_principal.test[0].id : data.azurerm_client_config.current.service_principal_object_id
}
# This provides the new AAD application the rights to managed, send and receive from the Event Hubs instance
resource "azurerm_role_assignment" "service_principal_eh" {
scope = "subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.test.name}/providers/Microsoft.EventHub/namespaces/${azurerm_eventhub_namespace.test.name}"
role_definition_name = "Azure Event Hubs Data Owner"
principal_id = data.azurerm_client_config.current.service_principal_application_id == "" ? azuread_service_principal.test[0].id : data.azurerm_client_config.current.service_principal_object_id
depends_on = [azurerm_eventhub_namespace.test]
}
output "TEST_EVENTHUB_RESOURCE_GROUP" {
value = "${azurerm_resource_group.test.name}"
value = azurerm_resource_group.test.name
}
output "EVENTHUB_CONNECTION_STRING" {
@ -112,30 +125,40 @@ output "EVENTHUB_CONNECTION_STRING" {
}
output "EVENTHUB_NAMESPACE" {
value = "${azurerm_eventhub_namespace.test.name}"
value = azurerm_eventhub_namespace.test.name
}
output "AZURE_SUBSCRIPTION_ID" {
value = "${data.azurerm_client_config.current.subscription_id}"
value = data.azurerm_client_config.current.subscription_id
}
output "TEST_EVENTHUB_LOCATION" {
value = "${var.location}"
value = var.location
}
output "AZURE_TENANT_ID" {
value = "${data.azurerm_client_config.current.tenant_id}"
value = data.azurerm_client_config.current.tenant_id
}
output "AZURE_CLIENT_ID" {
value = "${element(compact(concat(azurerm_azuread_application.test.*.application_id, list(data.azurerm_client_config.current.client_id))),0)}"
value = compact(
concat(
azuread_application.test.*.application_id,
list(data.azurerm_client_config.current.client_id)
)
)[0]
}
output "AZURE_CLIENT_SECRET" {
value = "${element(compact(concat(azurerm_azuread_service_principal_password.test.*.value, list(var.azure_client_secret))),0)}"
value = compact(
concat(
azuread_service_principal_password.test.*.value,
list(var.azure_client_secret)
)
)[0]
sensitive = true
}
output "STORAGE_ACCOUNT_NAME" {
value = "${azurerm_storage_account.test.name}"
value = azurerm_storage_account.test.name
}

Просмотреть файл

@ -43,6 +43,7 @@ const (
DefaultMaxMessageSizeInBytes MaxMessageSizeInBytes = 1000000
batchMessageWrapperSize = 100
// KeyOfNoPartitionKey is the key value in Events map for Events which do not have PartitionKey
KeyOfNoPartitionKey = "NoPartitionKey"
)

2
go.mod
Просмотреть файл

@ -1,5 +1,7 @@
module github.com/Azure/azure-event-hubs-go/v2
go 1.13
require (
github.com/Azure/azure-amqp-common-go/v2 v2.1.0
github.com/Azure/azure-pipeline-go v0.1.9