Make get(Region|Project|Zone) method testable (#1040)

This commit is contained in:
Vincent Roseberry 2018-02-02 10:55:43 -08:00 committed by GitHub
parent 47a8fe811b
commit 629c53be03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,13 +31,13 @@ func getRegionFromZone(zone string) string {
// - region extracted from the `zone` field in resource schema
// - provider-level region
// - region extracted from the provider-level zone
func getRegion(d *schema.ResourceData, config *Config) (string, error) {
func getRegion(d TerraformResourceData, config *Config) (string, error) {
return getRegionFromSchema("region", "zone", d, config)
}
// getZone reads the "zone" value from the given resource data and falls back
// to provider's value if not given. If neither is provided, returns an error.
func getZone(d *schema.ResourceData, config *Config) (string, error) {
func getZone(d TerraformResourceData, config *Config) (string, error) {
res, ok := d.GetOk("zone")
if !ok {
if config.Zone != "" {
@ -65,7 +65,7 @@ func getRegionFromInstanceState(is *terraform.InstanceState, config *Config) (st
// getProject reads the "project" field from the given resource data and falls
// back to the provider's value if not given. If the provider's value is not
// given, an error is returned.
func getProject(d *schema.ResourceData, config *Config) (string, error) {
func getProject(d TerraformResourceData, config *Config) (string, error) {
return getProjectFromSchema("project", d, config)
}