-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from heroku/issue/296/davidji99-upgrade-terra…
…formplugin Upgrade terraform-plugin-sdk to v2+
- Loading branch information
Showing
2,407 changed files
with
802 additions
and
679,203 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,5 +47,5 @@ jobs: | |
HEROKU_NON_ADMIN_TEST_USER: [email protected] | ||
HEROKU_SLUG_ID: 8527dbf3-c0a0-4255-beab-aca0aad1dfc9 | ||
HEROKU_USER_ID: 007fa6e2-00a1-429e-92a0-7bbe14b063fc | ||
GOFLAGS: "-mod=vendor" | ||
# GOFLAGS: "-mod=vendor" | ||
# TF_LOG: DEBUG |
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 |
---|---|---|
@@ -1,15 +1,14 @@ | ||
module github.com/heroku/terraform-provider-heroku/v3 | ||
module github.com/heroku/terraform-provider-heroku/v4 | ||
|
||
require ( | ||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d | ||
github.com/google/uuid v1.1.1 | ||
github.com/hashicorp/go-multierror v1.0.0 | ||
github.com/hashicorp/go-uuid v1.0.1 | ||
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect | ||
github.com/hashicorp/terraform-plugin-sdk v1.15.0 | ||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.3 | ||
github.com/heroku/heroku-go/v5 v5.2.1 | ||
github.com/mitchellh/go-homedir v1.1.0 | ||
github.com/verybluebot/tarinator-go v0.0.0-20190613183509-5ab4e1193986 | ||
) | ||
|
||
go 1.14 | ||
go 1.15 |
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
"strings" | ||
) | ||
|
||
const ( | ||
sentinelIndex = "*" | ||
) | ||
|
||
// The below few functions were copied from the AWS provider. | ||
|
||
// TestCheckTypeSetElemAttr is a resource.TestCheckFunc that accepts a resource | ||
// name, an attribute path, which should use the sentinel value '*' for indexing | ||
// into a TypeSet. The function verifies that an element matches the provided | ||
// value. | ||
// | ||
// Use this function over SDK provided TestCheckFunctions when validating a | ||
// TypeSet where its elements are a simple value | ||
func TestCheckTypeSetElemAttr(name, attr, value string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
is, err := instanceState(s, name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = testCheckTypeSetElem(is, attr, value) | ||
if err != nil { | ||
return fmt.Errorf("%q error: %s", name, err) | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
// TestCheckTypeSetElemAttrPair is a TestCheckFunc that verifies a pair of name/key | ||
// combinations are equal where the first uses the sentinel value to index into a | ||
// TypeSet. | ||
// | ||
// E.g., tfawsresource.TestCheckTypeSetElemAttrPair("aws_autoscaling_group.bar", "availability_zones.*", "data.aws_availability_zones.available", "names.0") | ||
func TestCheckTypeSetElemAttrPair(nameFirst, keyFirst, nameSecond, keySecond string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
isFirst, err := instanceState(s, nameFirst) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
isSecond, err := instanceState(s, nameSecond) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
vSecond, okSecond := isSecond.Attributes[keySecond] | ||
if !okSecond { | ||
return fmt.Errorf("%s: Attribute %q not set, cannot be checked against TypeSet", nameSecond, keySecond) | ||
} | ||
|
||
return testCheckTypeSetElem(isFirst, keyFirst, vSecond) | ||
} | ||
} | ||
|
||
// instanceState returns the primary instance state for the given | ||
// resource name in the root module. | ||
func instanceState(s *terraform.State, name string) (*terraform.InstanceState, error) { | ||
ms := s.RootModule() | ||
rs, ok := ms.Resources[name] | ||
if !ok { | ||
return nil, fmt.Errorf("Not found: %s in %s", name, ms.Path) | ||
} | ||
|
||
is := rs.Primary | ||
if is == nil { | ||
return nil, fmt.Errorf("No primary instance: %s in %s", name, ms.Path) | ||
} | ||
|
||
return is, nil | ||
} | ||
|
||
func testCheckTypeSetElem(is *terraform.InstanceState, attr, value string) error { | ||
attrParts := strings.Split(attr, ".") | ||
if attrParts[len(attrParts)-1] != sentinelIndex { | ||
return fmt.Errorf("%q does not end with the special value %q", attr, sentinelIndex) | ||
} | ||
for stateKey, stateValue := range is.Attributes { | ||
if stateValue == value { | ||
stateKeyParts := strings.Split(stateKey, ".") | ||
if len(stateKeyParts) == len(attrParts) { | ||
for i := range attrParts { | ||
if attrParts[i] != stateKeyParts[i] && attrParts[i] != sentinelIndex { | ||
break | ||
} | ||
if i == len(attrParts)-1 { | ||
return nil | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return fmt.Errorf("no TypeSet element %q, with value %q in state: %#v", attr, value, is.Attributes) | ||
} |
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.