Skip to content

Commit 91d5287

Browse files
authored
azurerm_batch_pool - support container_image_names property (#6689)
this is a pr which helps to configure docs.microsoft.com/en-us/dotnet/api/microsoft.azure.batch.containerconfiguration.containerimagenames?view=azure-dotnet
1 parent c2422bd commit 91d5287

16 files changed

+252
-217
lines changed

azurerm/helpers/azure/batch_account.go azurerm/internal/services/batch/batch_account.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package azure
1+
package batch
22

33
import (
44
"fmt"
55

66
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
77
)
88

9-
// ExpandBatchAccountKeyVaultReference expands Batch account KeyVault reference
10-
func ExpandBatchAccountKeyVaultReference(list []interface{}) (*batch.KeyVaultReference, error) {
9+
// expandBatchAccountKeyVaultReference expands Batch account KeyVault reference
10+
func expandBatchAccountKeyVaultReference(list []interface{}) (*batch.KeyVaultReference, error) {
1111
if len(list) == 0 {
1212
return nil, fmt.Errorf("Error: key vault reference should be defined")
1313
}
@@ -25,8 +25,8 @@ func ExpandBatchAccountKeyVaultReference(list []interface{}) (*batch.KeyVaultRef
2525
return ref, nil
2626
}
2727

28-
// FlattenBatchAccountKeyvaultReference flattens a Batch account keyvault reference
29-
func FlattenBatchAccountKeyvaultReference(keyVaultReference *batch.KeyVaultReference) interface{} {
28+
// flattenBatchAccountKeyvaultReference flattens a Batch account keyvault reference
29+
func flattenBatchAccountKeyvaultReference(keyVaultReference *batch.KeyVaultReference) interface{} {
3030
result := make(map[string]interface{})
3131

3232
if keyVaultReference == nil {

azurerm/internal/services/batch/batch_account_data_source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func dataSourceArmBatchAccountRead(d *schema.ResourceData, meta interface{}) err
118118
// set empty keyvault reference which is not needed in Batch Service allocation mode.
119119
d.Set("key_vault_reference", []interface{}{})
120120
} else if poolAllocationMode == string(batch.UserSubscription) {
121-
if err := d.Set("key_vault_reference", azure.FlattenBatchAccountKeyvaultReference(props.KeyVaultReference)); err != nil {
121+
if err := d.Set("key_vault_reference", flattenBatchAccountKeyvaultReference(props.KeyVaultReference)); err != nil {
122122
return fmt.Errorf("Error flattening `key_vault_reference`: %+v", err)
123123
}
124124
}

azurerm/internal/services/batch/tests/batch_account_data_source_test.go azurerm/internal/services/batch/batch_account_data_source_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tests
1+
package batch_test
22

33
import (
44
"fmt"
@@ -10,15 +10,15 @@ import (
1010
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
1111
)
1212

13-
func TestAccDataSourceAzureRMBatchAccount_basic(t *testing.T) {
13+
func TestAccBatchAccountDataSource_basic(t *testing.T) {
1414
data := acceptance.BuildTestData(t, "data.azurerm_batch_account", "test")
1515

1616
resource.ParallelTest(t, resource.TestCase{
1717
PreCheck: func() { acceptance.PreCheck(t) },
1818
Providers: acceptance.SupportedProviders,
1919
Steps: []resource.TestStep{
2020
{
21-
Config: testAccDataSourceAzureRMBatchAccount_basic(data),
21+
Config: testAccBatchAccountDataSource_basic(data),
2222
Check: resource.ComposeTestCheckFunc(
2323
resource.TestCheckResourceAttr(data.ResourceName, "name", fmt.Sprintf("testaccbatch%s", data.RandomString)),
2424
resource.TestCheckResourceAttr(data.ResourceName, "location", azure.NormalizeLocation(data.Locations.Primary)),
@@ -29,15 +29,15 @@ func TestAccDataSourceAzureRMBatchAccount_basic(t *testing.T) {
2929
})
3030
}
3131

32-
func TestAccDataSourceAzureRMBatchAccount_complete(t *testing.T) {
32+
func TestAccBatchAccountDataSource_complete(t *testing.T) {
3333
data := acceptance.BuildTestData(t, "data.azurerm_batch_account", "test")
3434

3535
resource.ParallelTest(t, resource.TestCase{
3636
PreCheck: func() { acceptance.PreCheck(t) },
3737
Providers: acceptance.SupportedProviders,
3838
Steps: []resource.TestStep{
3939
{
40-
Config: testAccDataSourceAzureRMBatchAccount_complete(data),
40+
Config: testAccBatchAccountDataSource_complete(data),
4141
Check: resource.ComposeTestCheckFunc(
4242
resource.TestCheckResourceAttr(data.ResourceName, "name", fmt.Sprintf("testaccbatch%s", data.RandomString)),
4343
resource.TestCheckResourceAttr(data.ResourceName, "location", azure.NormalizeLocation(data.Locations.Primary)),
@@ -50,7 +50,7 @@ func TestAccDataSourceAzureRMBatchAccount_complete(t *testing.T) {
5050
})
5151
}
5252

53-
func TestAccDataSourceAzureRMBatchAccount_userSubscription(t *testing.T) {
53+
func TestAccBatchAccountDataSource_userSubscription(t *testing.T) {
5454
data := acceptance.BuildTestData(t, "data.azurerm_batch_account", "test")
5555

5656
tenantID := os.Getenv("ARM_TENANT_ID")
@@ -61,7 +61,7 @@ func TestAccDataSourceAzureRMBatchAccount_userSubscription(t *testing.T) {
6161
Providers: acceptance.SupportedProviders,
6262
Steps: []resource.TestStep{
6363
{
64-
Config: testAccDataSourceAzureBatchAccount_userSubscription(data, tenantID, subscriptionID),
64+
Config: testAccBatchAccountDataSource_userSubscription(data, tenantID, subscriptionID),
6565
Check: resource.ComposeTestCheckFunc(
6666
resource.TestCheckResourceAttr(data.ResourceName, "name", fmt.Sprintf("testaccbatch%s", data.RandomString)),
6767
resource.TestCheckResourceAttr(data.ResourceName, "location", azure.NormalizeLocation(data.Locations.Primary)),
@@ -73,7 +73,7 @@ func TestAccDataSourceAzureRMBatchAccount_userSubscription(t *testing.T) {
7373
})
7474
}
7575

76-
func testAccDataSourceAzureRMBatchAccount_basic(data acceptance.TestData) string {
76+
func testAccBatchAccountDataSource_basic(data acceptance.TestData) string {
7777
return fmt.Sprintf(`
7878
provider "azurerm" {
7979
features {}
@@ -98,7 +98,7 @@ data "azurerm_batch_account" "test" {
9898
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
9999
}
100100

101-
func testAccDataSourceAzureRMBatchAccount_complete(data acceptance.TestData) string {
101+
func testAccBatchAccountDataSource_complete(data acceptance.TestData) string {
102102
return fmt.Sprintf(`
103103
provider "azurerm" {
104104
features {}
@@ -136,7 +136,7 @@ data "azurerm_batch_account" "test" {
136136
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString)
137137
}
138138

139-
func testAccDataSourceAzureBatchAccount_userSubscription(data acceptance.TestData, tenantID string, subscriptionID string) string {
139+
func testAccBatchAccountDataSource_userSubscription(data acceptance.TestData, tenantID string, subscriptionID string) string {
140140
return fmt.Sprintf(`
141141
provider "azurerm" {
142142
features {}

azurerm/internal/services/batch/batch_account_resource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func resourceArmBatchAccountCreate(d *schema.ResourceData, meta interface{}) err
143143
// if pool allocation mode is UserSubscription, a key vault reference needs to be set
144144
if poolAllocationMode == string(batch.UserSubscription) {
145145
keyVaultReferenceSet := d.Get("key_vault_reference").([]interface{})
146-
keyVaultReference, err := azure.ExpandBatchAccountKeyVaultReference(keyVaultReferenceSet)
146+
keyVaultReference, err := expandBatchAccountKeyVaultReference(keyVaultReferenceSet)
147147
if err != nil {
148148
return fmt.Errorf("Error creating Batch account %q (Resource Group %q): %+v", name, resourceGroup, err)
149149
}

azurerm/internal/services/batch/tests/batch_account_resource_test.go azurerm/internal/services/batch/batch_account_resource_test.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tests
1+
package batch_test
22

33
import (
44
"fmt"
@@ -42,68 +42,68 @@ func TestValidateBatchAccountName(t *testing.T) {
4242
}
4343
}
4444

45-
func TestAccAzureRMBatchAccount_basic(t *testing.T) {
45+
func TestAccBatchAccount_basic(t *testing.T) {
4646
data := acceptance.BuildTestData(t, "azurerm_batch_account", "test")
4747

4848
resource.ParallelTest(t, resource.TestCase{
4949
PreCheck: func() { acceptance.PreCheck(t) },
5050
Providers: acceptance.SupportedProviders,
51-
CheckDestroy: testCheckAzureRMBatchAccountDestroy,
51+
CheckDestroy: testCheckBatchAccountDestroy,
5252
Steps: []resource.TestStep{
5353
{
54-
Config: testAccAzureRMBatchAccount_basic(data),
54+
Config: testAccBatchAccount_basic(data),
5555
Check: resource.ComposeTestCheckFunc(
56-
testCheckAzureRMBatchAccountExists(data.ResourceName),
56+
testCheckBatchAccountExists(data.ResourceName),
5757
resource.TestCheckResourceAttr(data.ResourceName, "pool_allocation_mode", "BatchService"),
5858
),
5959
},
6060
},
6161
})
6262
}
6363

64-
func TestAccAzureRMBatchAccount_requiresImport(t *testing.T) {
64+
func TestAccBatchAccount_requiresImport(t *testing.T) {
6565
data := acceptance.BuildTestData(t, "azurerm_batch_account", "test")
6666

6767
resource.ParallelTest(t, resource.TestCase{
6868
PreCheck: func() { acceptance.PreCheck(t) },
6969
Providers: acceptance.SupportedProviders,
70-
CheckDestroy: testCheckAzureRMBatchAccountDestroy,
70+
CheckDestroy: testCheckBatchAccountDestroy,
7171
Steps: []resource.TestStep{
7272
{
73-
Config: testAccAzureRMBatchAccount_basic(data),
73+
Config: testAccBatchAccount_basic(data),
7474
Check: resource.ComposeTestCheckFunc(
75-
testCheckAzureRMBatchAccountExists(data.ResourceName),
75+
testCheckBatchAccountExists(data.ResourceName),
7676
),
7777
},
7878
{
79-
Config: testAccAzureRMBatchAccount_requiresImport(data),
79+
Config: testAccBatchAccount_requiresImport(data),
8080
ExpectError: acceptance.RequiresImportError("azurerm_batch_account"),
8181
},
8282
},
8383
})
8484
}
8585

86-
func TestAccAzureRMBatchAccount_complete(t *testing.T) {
86+
func TestAccBatchAccount_complete(t *testing.T) {
8787
data := acceptance.BuildTestData(t, "azurerm_batch_account", "test")
8888

8989
resource.ParallelTest(t, resource.TestCase{
9090
PreCheck: func() { acceptance.PreCheck(t) },
9191
Providers: acceptance.SupportedProviders,
92-
CheckDestroy: testCheckAzureRMBatchAccountDestroy,
92+
CheckDestroy: testCheckBatchAccountDestroy,
9393
Steps: []resource.TestStep{
9494
{
95-
Config: testAccAzureRMBatchAccount_complete(data),
95+
Config: testAccBatchAccount_complete(data),
9696
Check: resource.ComposeTestCheckFunc(
97-
testCheckAzureRMBatchAccountExists(data.ResourceName),
97+
testCheckBatchAccountExists(data.ResourceName),
9898
resource.TestCheckResourceAttr(data.ResourceName, "pool_allocation_mode", "BatchService"),
9999
resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"),
100100
resource.TestCheckResourceAttr(data.ResourceName, "tags.env", "test"),
101101
),
102102
},
103103
{
104-
Config: testAccAzureRMBatchAccount_completeUpdated(data),
104+
Config: testAccBatchAccount_completeUpdated(data),
105105
Check: resource.ComposeTestCheckFunc(
106-
testCheckAzureRMBatchAccountExists(data.ResourceName),
106+
testCheckBatchAccountExists(data.ResourceName),
107107
resource.TestCheckResourceAttr(data.ResourceName, "pool_allocation_mode", "BatchService"),
108108
resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "2"),
109109
resource.TestCheckResourceAttr(data.ResourceName, "tags.env", "test"),
@@ -114,27 +114,27 @@ func TestAccAzureRMBatchAccount_complete(t *testing.T) {
114114
})
115115
}
116116

117-
func TestAccAzureRMBatchAccount_userSubscription(t *testing.T) {
117+
func TestAccBatchAccount_userSubscription(t *testing.T) {
118118
data := acceptance.BuildTestData(t, "azurerm_batch_account", "test")
119119
tenantID := os.Getenv("ARM_TENANT_ID")
120120

121121
resource.ParallelTest(t, resource.TestCase{
122122
PreCheck: func() { acceptance.PreCheck(t) },
123123
Providers: acceptance.SupportedProviders,
124-
CheckDestroy: testCheckAzureRMBatchAccountDestroy,
124+
CheckDestroy: testCheckBatchAccountDestroy,
125125
Steps: []resource.TestStep{
126126
{
127-
Config: testAccAzureRMBatchAccount_userSubscription(data, tenantID),
127+
Config: testAccBatchAccount_userSubscription(data, tenantID),
128128
Check: resource.ComposeTestCheckFunc(
129-
testCheckAzureRMBatchAccountExists(data.ResourceName),
129+
testCheckBatchAccountExists(data.ResourceName),
130130
resource.TestCheckResourceAttr(data.ResourceName, "pool_allocation_mode", "UserSubscription"),
131131
),
132132
},
133133
},
134134
})
135135
}
136136

137-
func testCheckAzureRMBatchAccountExists(resourceName string) resource.TestCheckFunc {
137+
func testCheckBatchAccountExists(resourceName string) resource.TestCheckFunc {
138138
return func(s *terraform.State) error {
139139
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
140140
conn := acceptance.AzureProvider.Meta().(*clients.Client).Batch.AccountClient
@@ -165,7 +165,7 @@ func testCheckAzureRMBatchAccountExists(resourceName string) resource.TestCheckF
165165
}
166166
}
167167

168-
func testCheckAzureRMBatchAccountDestroy(s *terraform.State) error {
168+
func testCheckBatchAccountDestroy(s *terraform.State) error {
169169
conn := acceptance.AzureProvider.Meta().(*clients.Client).Batch.AccountClient
170170
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
171171

@@ -192,7 +192,7 @@ func testCheckAzureRMBatchAccountDestroy(s *terraform.State) error {
192192
return nil
193193
}
194194

195-
func testAccAzureRMBatchAccount_basic(data acceptance.TestData) string {
195+
func testAccBatchAccount_basic(data acceptance.TestData) string {
196196
return fmt.Sprintf(`
197197
provider "azurerm" {
198198
features {}
@@ -212,8 +212,8 @@ resource "azurerm_batch_account" "test" {
212212
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
213213
}
214214

215-
func testAccAzureRMBatchAccount_requiresImport(data acceptance.TestData) string {
216-
template := testAccAzureRMBatchAccount_basic(data)
215+
func testAccBatchAccount_requiresImport(data acceptance.TestData) string {
216+
template := testAccBatchAccount_basic(data)
217217
return fmt.Sprintf(`
218218
%s
219219
resource "azurerm_batch_account" "import" {
@@ -225,7 +225,7 @@ resource "azurerm_batch_account" "import" {
225225
`, template)
226226
}
227227

228-
func testAccAzureRMBatchAccount_complete(data acceptance.TestData) string {
228+
func testAccBatchAccount_complete(data acceptance.TestData) string {
229229
return fmt.Sprintf(`
230230
provider "azurerm" {
231231
features {}
@@ -258,7 +258,7 @@ resource "azurerm_batch_account" "test" {
258258
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString)
259259
}
260260

261-
func testAccAzureRMBatchAccount_completeUpdated(data acceptance.TestData) string {
261+
func testAccBatchAccount_completeUpdated(data acceptance.TestData) string {
262262
return fmt.Sprintf(`
263263
provider "azurerm" {
264264
features {}
@@ -292,7 +292,7 @@ resource "azurerm_batch_account" "test" {
292292
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString)
293293
}
294294

295-
func testAccAzureRMBatchAccount_userSubscription(data acceptance.TestData, tenantID string) string {
295+
func testAccBatchAccount_userSubscription(data acceptance.TestData, tenantID string) string {
296296
return fmt.Sprintf(`
297297
provider "azurerm" {
298298
features {}

azurerm/internal/services/batch/tests/batch_application_resource_test.go azurerm/internal/services/batch/batch_application_resource_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tests
1+
package batch_test
22

33
import (
44
"fmt"
@@ -12,52 +12,52 @@ import (
1212
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
1313
)
1414

15-
func TestAccAzureRMBatchApplication_basic(t *testing.T) {
15+
func TestAccBatchApplication_basic(t *testing.T) {
1616
data := acceptance.BuildTestData(t, "azurerm_batch_application", "test")
1717

1818
resource.ParallelTest(t, resource.TestCase{
1919
PreCheck: func() { acceptance.PreCheck(t) },
2020
Providers: acceptance.SupportedProviders,
21-
CheckDestroy: testCheckAzureRMBatchApplicationDestroy,
21+
CheckDestroy: testCheckBatchApplicationDestroy,
2222
Steps: []resource.TestStep{
2323
{
24-
Config: testAccAzureRMBatchApplication_template(data, ""),
24+
Config: testAccBatchApplication_template(data, ""),
2525
Check: resource.ComposeTestCheckFunc(
26-
testCheckAzureRMBatchApplicationExists(data.ResourceName),
26+
testCheckBatchApplicationExists(data.ResourceName),
2727
),
2828
},
2929
data.ImportStep(),
3030
},
3131
})
3232
}
3333

34-
func TestAccAzureRMBatchApplication_update(t *testing.T) {
34+
func TestAccBatchApplication_update(t *testing.T) {
3535
data := acceptance.BuildTestData(t, "azurerm_batch_application", "test")
3636
displayName := fmt.Sprintf("TestAccDisplayName-%d", data.RandomInteger)
3737

3838
resource.ParallelTest(t, resource.TestCase{
3939
PreCheck: func() { acceptance.PreCheck(t) },
4040
Providers: acceptance.SupportedProviders,
41-
CheckDestroy: testCheckAzureRMBatchApplicationDestroy,
41+
CheckDestroy: testCheckBatchApplicationDestroy,
4242
Steps: []resource.TestStep{
4343
{
44-
Config: testAccAzureRMBatchApplication_template(data, ""),
44+
Config: testAccBatchApplication_template(data, ""),
4545
Check: resource.ComposeTestCheckFunc(
46-
testCheckAzureRMBatchApplicationExists(data.ResourceName),
46+
testCheckBatchApplicationExists(data.ResourceName),
4747
),
4848
},
4949
{
50-
Config: testAccAzureRMBatchApplication_template(data, fmt.Sprintf(`display_name = "%s"`, displayName)),
50+
Config: testAccBatchApplication_template(data, fmt.Sprintf(`display_name = "%s"`, displayName)),
5151
Check: resource.ComposeTestCheckFunc(
52-
testCheckAzureRMBatchApplicationExists(data.ResourceName),
52+
testCheckBatchApplicationExists(data.ResourceName),
5353
resource.TestCheckResourceAttr(data.ResourceName, "display_name", displayName),
5454
),
5555
},
5656
},
5757
})
5858
}
5959

60-
func testCheckAzureRMBatchApplicationExists(resourceName string) resource.TestCheckFunc {
60+
func testCheckBatchApplicationExists(resourceName string) resource.TestCheckFunc {
6161
return func(s *terraform.State) error {
6262
client := acceptance.AzureProvider.Meta().(*clients.Client).Batch.ApplicationClient
6363
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
@@ -83,7 +83,7 @@ func testCheckAzureRMBatchApplicationExists(resourceName string) resource.TestCh
8383
}
8484
}
8585

86-
func testCheckAzureRMBatchApplicationDestroy(s *terraform.State) error {
86+
func testCheckBatchApplicationDestroy(s *terraform.State) error {
8787
client := acceptance.AzureProvider.Meta().(*clients.Client).Batch.ApplicationClient
8888
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
8989

@@ -109,7 +109,7 @@ func testCheckAzureRMBatchApplicationDestroy(s *terraform.State) error {
109109
return nil
110110
}
111111

112-
func testAccAzureRMBatchApplication_template(data acceptance.TestData, displayName string) string {
112+
func testAccBatchApplication_template(data acceptance.TestData, displayName string) string {
113113
return fmt.Sprintf(`
114114
provider "azurerm" {
115115
features {}

0 commit comments

Comments
 (0)