mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Remove unnecessary StateFunc in compute_target_https_proxy (#1027)
* Remove unnecessary StateFunc in https proxy * Support name only certificates * Remove test for the removed validate func
This commit is contained in:
parent
0386cbcd2b
commit
559f28016f
@ -5,14 +5,11 @@ import (
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"regexp"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"google.golang.org/api/compute/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
sslCertificateRegex = "projects/(.+)/global/sslCertificates/(.+)$"
|
||||
canonicalSslCertificateTemplate = "https://www.googleapis.com/compute/v1/projects/%s/global/sslCertificates/%s"
|
||||
)
|
||||
|
||||
@ -38,9 +35,8 @@ func resourceComputeTargetHttpsProxy() *schema.Resource {
|
||||
Type: schema.TypeList,
|
||||
Required: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validateRegexp(sslCertificateRegex),
|
||||
StateFunc: toCanonicalSslCertificate,
|
||||
Type: schema.TypeString,
|
||||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||
},
|
||||
},
|
||||
|
||||
@ -83,11 +79,9 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac
|
||||
return err
|
||||
}
|
||||
|
||||
_sslCertificates := d.Get("ssl_certificates").([]interface{})
|
||||
sslCertificates := make([]string, len(_sslCertificates))
|
||||
|
||||
for i, v := range _sslCertificates {
|
||||
sslCertificates[i] = v.(string)
|
||||
sslCertificates, err := expandSslCertificates(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
proxy := &compute.TargetHttpsProxy{
|
||||
@ -145,7 +139,10 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac
|
||||
}
|
||||
|
||||
if d.HasChange("ssl_certificates") {
|
||||
certs := convertStringArr(d.Get("ssl_certificates").([]interface{}))
|
||||
certs, err := expandSslCertificates(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cert_ref := &compute.TargetHttpsProxiesSetSslCertificatesRequest{
|
||||
SslCertificates: certs,
|
||||
}
|
||||
@ -217,10 +214,3 @@ func resourceComputeTargetHttpsProxyDelete(d *schema.ResourceData, meta interfac
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
|
||||
func toCanonicalSslCertificate(v interface{}) string {
|
||||
value := v.(string)
|
||||
m := regexp.MustCompile(sslCertificateRegex).FindStringSubmatch(value)
|
||||
|
||||
return fmt.Sprintf(canonicalSslCertificateTemplate, m[1], m[2])
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"google.golang.org/api/compute/v1"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func TestAccComputeTargetHttpsProxy_basic(t *testing.T) {
|
||||
@ -75,24 +74,6 @@ func TestAccComputeTargetHttpsProxy_update(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccComputeTargetHttpsProxy_invalidCertificate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resourceSuffix := acctest.RandString(10)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeTargetHttpsProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeTargetHttpsProxy_invalidCertificate(resourceSuffix),
|
||||
ExpectError: regexp.MustCompile("ssl_certificate"),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckComputeTargetHttpsProxyDestroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
@ -284,13 +265,3 @@ resource "google_compute_ssl_certificate" "foobar2" {
|
||||
}
|
||||
`, id, id, id, id, id, id)
|
||||
}
|
||||
|
||||
func testAccComputeTargetHttpsProxy_invalidCertificate(id string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_https_proxy" "foobar" {
|
||||
name = "httpsproxy-test-%s"
|
||||
url_map = "some-url-map"
|
||||
ssl_certificates = ["invalid-certificate-reference"]
|
||||
}
|
||||
`, id)
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ The following arguments are supported:
|
||||
* `name` - (Required) A unique name for the resource, required by GCE. Changing
|
||||
this forces a new resource to be created.
|
||||
|
||||
* `ssl_certificates` - (Required) The URLs of the SSL Certificate resources that
|
||||
authenticate connections between users and load balancing.
|
||||
* `ssl_certificates` - (Required) The URLs or names of the SSL Certificate resources
|
||||
that authenticate connections between users and load balancing.
|
||||
|
||||
* `url_map` - (Required) The URL of a URL Map resource that defines the mapping
|
||||
from the URL to the BackendService.
|
||||
|
@ -54,7 +54,7 @@ The following arguments are supported:
|
||||
|
||||
* `backend_service` - (Required) The URL of a Backend Service resource to receive the matched traffic.
|
||||
|
||||
* `ssl_certificates` - (Required) The URLs of the SSL Certificate resources that
|
||||
* `ssl_certificates` - (Required) The URLs or names of the SSL Certificate resources that
|
||||
authenticate connections between users and load balancing.
|
||||
|
||||
- - -
|
||||
|
Loading…
Reference in New Issue
Block a user