Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps: support removing ingress rules. #1276

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}
}
}`
Loading