mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-06 18:51:13 +00:00
Use healthcheck names instead of urls when reading target pool
- Resolves #8488 Signed-off-by: Dan Wendorf <dwendorf@pivotal.io>
This commit is contained in:
parent
2477c7c5a5
commit
4189b6f30b
@ -362,6 +362,16 @@ func convertInstancesFromUrls(urls []string) []string {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertHealthChecksFromUrls(urls []string) []string {
|
||||||
|
result := make([]string, 0, len(urls))
|
||||||
|
for _, url := range urls {
|
||||||
|
urlArray := strings.Split(url, "/")
|
||||||
|
healthCheck := fmt.Sprintf("%s", urlArray[len(urlArray)-1])
|
||||||
|
result = append(result, healthCheck)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
config := meta.(*Config)
|
config := meta.(*Config)
|
||||||
|
|
||||||
@ -394,7 +404,11 @@ func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) err
|
|||||||
d.Set("backup_pool", tpool.BackupPool)
|
d.Set("backup_pool", tpool.BackupPool)
|
||||||
d.Set("description", tpool.Description)
|
d.Set("description", tpool.Description)
|
||||||
d.Set("failover_ratio", tpool.FailoverRatio)
|
d.Set("failover_ratio", tpool.FailoverRatio)
|
||||||
d.Set("health_checks", tpool.HealthChecks)
|
if tpool.HealthChecks != nil {
|
||||||
|
d.Set("health_checks", convertHealthChecksFromUrls(tpool.HealthChecks))
|
||||||
|
} else {
|
||||||
|
d.Set("health_checks", nil)
|
||||||
|
}
|
||||||
if tpool.Instances != nil {
|
if tpool.Instances != nil {
|
||||||
d.Set("instances", convertInstancesFromUrls(tpool.Instances))
|
d.Set("instances", convertInstancesFromUrls(tpool.Instances))
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,9 +73,17 @@ func testAccCheckComputeTargetPoolExists(n string) resource.TestCheckFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testAccComputeTargetPool_basic = fmt.Sprintf(`
|
var testAccComputeTargetPool_basic = fmt.Sprintf(`
|
||||||
|
resource "google_compute_http_health_check" "foobar" {
|
||||||
|
name = "healthcheck-test-%s"
|
||||||
|
host = "example.com"
|
||||||
|
}
|
||||||
|
|
||||||
resource "google_compute_target_pool" "foobar" {
|
resource "google_compute_target_pool" "foobar" {
|
||||||
description = "Resource created for Terraform acceptance testing"
|
description = "Resource created for Terraform acceptance testing"
|
||||||
instances = ["us-central1-a/foo", "us-central1-b/bar"]
|
instances = ["us-central1-a/foo", "us-central1-b/bar"]
|
||||||
name = "tpool-test-%s"
|
name = "tpool-test-%s"
|
||||||
session_affinity = "CLIENT_IP_PROTO"
|
session_affinity = "CLIENT_IP_PROTO"
|
||||||
}`, acctest.RandString(10))
|
health_checks = [
|
||||||
|
"${google_compute_http_health_check.foobar.name}"
|
||||||
|
]
|
||||||
|
}`, acctest.RandString(10), acctest.RandString(10))
|
||||||
|
Loading…
Reference in New Issue
Block a user