Skip to content

Commit

Permalink
[Batch Pool] Fix issue when setting multiple env var in pool start ta…
Browse files Browse the repository at this point in the history
…sk (#2685)

This PR fixes #2673.
Was just a value capture issue inside a for loop.
I've added unit test to reproduce the issue and committed a fix.
  • Loading branch information
jcorioland authored and katbyte committed Jan 17, 2019
1 parent b81356e commit 3b32b8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions azurerm/helpers/azure/batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,11 @@ func ExpandBatchPoolStartTask(list []interface{}) (*batch.StartTask, error) {
envSettings := make([]batch.EnvironmentSetting, 0)

for k, v := range envMap {
envValue := v.(string)
theValue := v.(string)
theKey := k
envSetting := batch.EnvironmentSetting{
Name: &k,
Value: &envValue,
Name: &theKey,
Value: &theValue,
}

envSettings = append(envSettings, envSetting)
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_batch_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ func TestAccAzureRMBatchPoolStartTask_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "fixed_scale.0.target_low_priority_nodes", "0"),
resource.TestCheckResourceAttr(resourceName, "start_task.#", "1"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.max_task_retry_count", "1"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.environment.%", "1"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.environment.%", "2"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.environment.env", "TEST"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.environment.bu", "Research&Dev"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.user_identity.#", "1"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.user_identity.0.auto_user.#", "1"),
resource.TestCheckResourceAttr(resourceName, "start_task.0.user_identity.0.auto_user.0.scope", "Task"),
Expand Down Expand Up @@ -449,7 +450,8 @@ resource "azurerm_batch_pool" "test" {
wait_for_success = true
environment {
env = "TEST"
env = "TEST",
bu = "Research&Dev"
}
user_identity {
Expand Down

0 comments on commit 3b32b8b

Please sign in to comment.