-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate configuration field in deployment resource
- Loading branch information
1 parent
d15c7ea
commit 4a6a89b
Showing
2 changed files
with
308 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,41 @@ func TestAccNginxDeployment_systemAssignedIdentity(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccNginxDeployment_withConfiguration(t *testing.T) { | ||
data := acceptance.BuildTestData(t, nginx.DeploymentResource{}.ResourceType(), "test") | ||
r := DeploymentResource{} | ||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.withConfiguration(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccNginxDeployment_updateWithConfiguration(t *testing.T) { | ||
data := acceptance.BuildTestData(t, nginx.DeploymentResource{}.ResourceType(), "test") | ||
r := DeploymentResource{} | ||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.basic(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
{ | ||
Config: r.withConfiguration(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccNginxDeployment_userAssignedIdentity(t *testing.T) { | ||
data := acceptance.BuildTestData(t, nginx.DeploymentResource{}.ResourceType(), "test") | ||
r := DeploymentResource{} | ||
|
@@ -100,8 +135,6 @@ func (a DeploymentResource) basic(data acceptance.TestData) string { | |
return fmt.Sprintf(` | ||
%s | ||
resource "azurerm_nginx_deployment" "test" { | ||
|
@@ -217,6 +250,82 @@ resource "azurerm_nginx_deployment" "test" { | |
`, a.template(data), data.RandomInteger, data.Locations.Primary) | ||
} | ||
|
||
func (a DeploymentResource) withConfiguration(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%s | ||
locals { | ||
config_content = base64encode(<<-EOT | ||
http { | ||
server { | ||
listen 80; | ||
location / { | ||
auth_basic "Protected Area"; | ||
auth_basic_user_file /opt/.htpasswd; | ||
default_type text/html; | ||
return 200 '<!doctype html><html lang="en"><head></head><body> | ||
<div>this one will be updated</div> | ||
<div>at 10:38 am</div> | ||
</body></html>'; | ||
} | ||
include site/*.conf; | ||
} | ||
} | ||
EOT | ||
) | ||
protected_content = base64encode(<<-EOT | ||
user:$apr1$VeUA5kt.$IjjRk//8miRxDsZvD4daF1 | ||
EOT | ||
) | ||
sub_config_content = base64encode(<<-EOT | ||
location /bbb { | ||
default_type text/html; | ||
return 200 '<!doctype html><html lang="en"><head></head><body> | ||
<div>this one will be updated</div> | ||
<div>at 10:38 am</div> | ||
</body></html>'; | ||
} | ||
EOT | ||
) | ||
} | ||
resource "azurerm_nginx_deployment" "test" { | ||
name = "acctest-%[2]d" | ||
resource_group_name = azurerm_resource_group.test.name | ||
sku = "standard_Monthly" | ||
location = azurerm_resource_group.test.location | ||
diagnose_support_enabled = true | ||
frontend_public { | ||
ip_address = [azurerm_public_ip.test.id] | ||
} | ||
network_interface { | ||
subnet_id = azurerm_subnet.test.id | ||
} | ||
capacity = 10 | ||
email = "[email protected]" | ||
configuration { | ||
root_file = "/etc/nginx/nginx.conf" | ||
config_file { | ||
content = local.config_content | ||
virtual_path = "/etc/nginx/nginx.conf" | ||
} | ||
config_file { | ||
content = local.sub_config_content | ||
virtual_path = "/etc/nginx/site/b.conf" | ||
} | ||
protected_file { | ||
content = local.protected_content | ||
virtual_path = "/opt/.htpasswd" | ||
} | ||
} | ||
tags = { | ||
foo = "bar" | ||
} | ||
lifecycle { | ||
ignore_changes = [configuration.0.protected_file] | ||
} | ||
} | ||
`, a.template(data), data.RandomInteger, data.Locations.Primary) | ||
} | ||
|
||
func (a DeploymentResource) update(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
|