From c5e9710e677995a15bb67412d75d1bd3b95fac7e Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Mon, 25 Nov 2024 10:41:26 -0500 Subject: [PATCH] apps: support removing ingress rules. --- digitalocean/app/app_spec.go | 1 - digitalocean/app/resource_app_test.go | 92 +++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/digitalocean/app/app_spec.go b/digitalocean/app/app_spec.go index 60b9ce638..dbbaedc2d 100644 --- a/digitalocean/app/app_spec.go +++ b/digitalocean/app/app_spec.go @@ -1033,7 +1033,6 @@ func appSpecIngressSchema() *schema.Resource { "rule": { Type: schema.TypeList, Optional: true, - Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "match": { diff --git a/digitalocean/app/resource_app_test.go b/digitalocean/app/resource_app_test.go index 63caec9e9..41095cf4a 100644 --- a/digitalocean/app/resource_app_test.go +++ b/digitalocean/app/resource_app_test.go @@ -865,6 +865,55 @@ func TestAccDigitalOceanApp_TimeoutConfig(t *testing.T) { }) } +func TestAccDigitalOceanApp_makeServiceInternal(t *testing.T) { + var app godo.App + appName := acceptance.RandomTestName() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: testAccCheckDigitalOceanAppDestroy, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(testAccCheckDigitalOceanAppConfig_minimalService, appName), + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanAppExists("digitalocean_app.foobar", &app), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.name", appName, + ), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.ingress.0.rule.0.match.0.path.0.prefix", "/", + ), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.service.0.http_port", "8080", + ), + ), + }, + { + Config: fmt.Sprintf(testAccCheckDigitalOceanAppConfig_internalOnlyService, appName), + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanAppExists("digitalocean_app.foobar", &app), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.name", appName, + ), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.service.0.http_port", "0", + ), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.service.0.internal_ports.#", "1", + ), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.service.0.internal_ports.0", "8080", + ), + resource.TestCheckResourceAttr( + "digitalocean_app.foobar", "spec.0.ingress.0.rule.#", "0", + ), + ), + }, + }, + }) +} + func testAccCheckDigitalOceanAppDestroy(s *terraform.State) error { client := acceptance.TestAccProvider.Meta().(*config.CombinedConfig).GodoClient() @@ -1577,3 +1626,46 @@ resource "digitalocean_app" "foobar" { } } }` + +var testAccCheckDigitalOceanAppConfig_minimalService = ` +resource "digitalocean_app" "foobar" { + spec { + name = "%s" + region = "nyc" + + service { + name = "go-service" + instance_count = 1 + instance_size_slug = "apps-d-1vcpu-0.5gb" + + git { + repo_clone_url = "https://github.com/digitalocean/sample-golang.git" + branch = "main" + } + } + } +}` + +var testAccCheckDigitalOceanAppConfig_internalOnlyService = ` +resource "digitalocean_app" "foobar" { + spec { + name = "%s" + region = "nyc" + + service { + name = "go-service" + instance_count = 1 + instance_size_slug = "apps-d-1vcpu-0.5gb" + + http_port = 0 + internal_ports = [8080] + + git { + repo_clone_url = "https://github.com/digitalocean/sample-golang.git" + branch = "main" + } + } + + ingress {} + } +}`