Skip to content

Commit

Permalink
Fix Private Space create without DataCIDR (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars authored Jun 15, 2023
1 parent 69a18b0 commit 49d4874
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions heroku/resource_heroku_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func resourceHerokuSpace() *schema.Resource {

"data_cidr": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Default: "10.1.0.0/16",
ForceNew: true,
},

Expand Down Expand Up @@ -97,12 +97,12 @@ func resourceHerokuSpaceCreate(d *schema.ResourceData, meta interface{}) error {
opts.Shield = &vs
}

if v := d.Get("cidr"); v != nil {
if v, ok := d.GetOk("cidr"); ok {
vs := v.(string)
opts.CIDR = &vs
}

if v := d.Get("data_cidr"); v != nil {
if v, ok := d.GetOk("data_cidr"); ok {
vs := v.(string)
opts.DataCIDR = &vs
}
Expand Down
9 changes: 4 additions & 5 deletions heroku/resource_heroku_space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestAccHerokuSpace(t *testing.T) {
var space spaceWithNAT
spaceName := fmt.Sprintf("tftest1-%s", acctest.RandString(10))
org := testAccConfig.GetAnyOrganizationOrSkip(t)
spaceConfig := testAccCheckHerokuSpaceConfig_basic(spaceName, org, "10.0.0.0/16", "10.1.0.0/20")
spaceConfig := testAccCheckHerokuSpaceConfig_basic(spaceName, org, "10.0.0.0/16")

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -30,7 +30,7 @@ func TestAccHerokuSpace(t *testing.T) {
testAccCheckHerokuSpaceExists("heroku_space.foobar", &space),
resource.TestCheckResourceAttrSet("heroku_space.foobar", "outbound_ips.#"),
resource.TestCheckResourceAttr("heroku_space.foobar", "cidr", "10.0.0.0/16"),
resource.TestCheckResourceAttr("heroku_space.foobar", "data_cidr", "10.1.0.0/20"),
resource.TestCheckResourceAttrSet("heroku_space.foobar", "data_cidr"),
),
},
// append space test Steps, sharing the space, instead of recreating for each test
Expand All @@ -54,16 +54,15 @@ func TestAccHerokuSpace(t *testing.T) {
// …
// }

func testAccCheckHerokuSpaceConfig_basic(spaceName, orgName, cidr, dataCidr string) string {
func testAccCheckHerokuSpaceConfig_basic(spaceName, orgName, cidr string) string {
return fmt.Sprintf(`
resource "heroku_space" "foobar" {
name = "%s"
organization = "%s"
region = "virginia"
cidr = "%s"
data_cidr = "%s"
}
`, spaceName, orgName, cidr, dataCidr)
`, spaceName, orgName, cidr)
}

func testAccCheckHerokuSpaceExists(n string, space *spaceWithNAT) resource.TestCheckFunc {
Expand Down

0 comments on commit 49d4874

Please sign in to comment.