Skip to content

Commit

Permalink
azurerm_container_app - allow multiple container blocks (#20423)
Browse files Browse the repository at this point in the history
  • Loading branch information
bikerpatch committed Feb 17, 2023
1 parent 06290b7 commit d5d343b
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 2 deletions.
141 changes: 141 additions & 0 deletions internal/services/containerapps/container_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ func TestAccContainerAppResource_completeWithVNet(t *testing.T) {
})
}

func TestAccContainerAppResource_completeWithSidecar(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_app", "test")
r := ContainerAppResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.completeWithSidecar(data, "rev1"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccContainerAppResource_completeUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_app", "test")
r := ContainerAppResource{}
Expand Down Expand Up @@ -546,6 +561,132 @@ resource "azurerm_container_app" "test" {
`, r.templateWithVnet(data), data.RandomInteger, revisionSuffix)
}

func (r ContainerAppResource) completeWithSidecar(data acceptance.TestData, revisionSuffix string) string {
return fmt.Sprintf(`
%s
resource "azurerm_container_app" "test" {
name = "acctest-capp-%[2]d"
resource_group_name = azurerm_resource_group.test.name
container_app_environment_id = azurerm_container_app_environment.test.id
revision_mode = "Single"
template {
container {
name = "acctest-cont-sidecar-%[2]d"
image = "jackofallops/azure-containerapps-python-acctest:v0.0.1"
cpu = 0.25
memory = "0.5Gi"
readiness_probe {
transport = "HTTP"
port = 5000
}
liveness_probe {
transport = "HTTP"
port = 5000
path = "/health"
header {
name = "Cache-Control"
value = "no-cache"
}
initial_delay = 5
timeout = 2
failure_count_threshold = 1
}
startup_probe {
transport = "TCP"
port = 5000
}
volume_mounts {
name = azurerm_container_app_environment_storage.test.name
path = "/tmp/testdata"
}
}
container {
name = "acctest-cont-%[2]d"
image = "jackofallops/azure-containerapps-python-acctest:v0.0.1"
cpu = 0.25
memory = "0.5Gi"
readiness_probe {
transport = "HTTP"
port = 5000
}
liveness_probe {
transport = "HTTP"
port = 5000
path = "/health"
header {
name = "Cache-Control"
value = "no-cache"
}
initial_delay = 5
timeout = 2
failure_count_threshold = 1
}
startup_probe {
transport = "TCP"
port = 5000
}
volume_mounts {
name = azurerm_container_app_environment_storage.test.name
path = "/tmp/testdata"
}
}
volume {
name = azurerm_container_app_environment_storage.test.name
storage_type = "AzureFile"
storage_name = azurerm_container_app_environment_storage.test.name
}
min_replicas = 2
max_replicas = 3
revision_suffix = "%[3]s"
}
ingress {
allow_insecure_connections = true
target_port = 5000
transport = "http"
traffic_weight {
latest_revision = true
percentage = 100
}
}
registry {
server = azurerm_container_registry.test.login_server
username = azurerm_container_registry.test.admin_username
password_secret_name = "registry-password"
}
secret {
name = "registry-password"
value = azurerm_container_registry.test.admin_password
}
tags = {
foo = "Bar"
accTest = "1"
}
}
`, r.templatePlusExtras(data), data.RandomInteger, revisionSuffix)
}

func (r ContainerAppResource) completeChangedSecret(data acceptance.TestData, revisionSuffix string) string {
return fmt.Sprintf(`
%s
Expand Down
1 change: 0 additions & 1 deletion internal/services/containerapps/helpers/container_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ func ContainerAppContainerSchema() *pluginsdk.Schema {
Type: pluginsdk.TypeList,
Required: true,
MinItems: 1,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"name": {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/container_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ A `secret` block supports the following:

A `template` block supports the following:

* `container` - (Required) A `container` block as detailed below.
* `container` - (Required) One or more `container` blocks as detailed below.

* `max_replicas` - (Optional) The maximum number of replicas for this container.

Expand Down

0 comments on commit d5d343b

Please sign in to comment.