Skip to content

Commit

Permalink
apps: support removing ingress rules. (#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething authored Nov 25, 2024
1 parent d25af35 commit 2be8621
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
1 change: 0 additions & 1 deletion digitalocean/app/app_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
92 changes: 92 additions & 0 deletions digitalocean/app/resource_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 {}
}
}`

0 comments on commit 2be8621

Please sign in to comment.