Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ssl_policy to use v1 API #1368

Merged
merged 2 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions google/resource_compute_ssl_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
computeBeta "google.golang.org/api/compute/v0.beta"
compute "google.golang.org/api/compute/v1"
)

func resourceComputeSslPolicy() *schema.Resource {
Expand Down Expand Up @@ -120,15 +120,15 @@ func resourceComputeSslPolicyCreate(d *schema.ResourceData, meta interface{}) er
return err
}

sslPolicy := &computeBeta.SslPolicy{
sslPolicy := &compute.SslPolicy{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Profile: d.Get("profile").(string),
MinTlsVersion: d.Get("min_tls_version").(string),
CustomFeatures: convertStringSet(d.Get("custom_features").(*schema.Set)),
}

op, err := config.clientComputeBeta.SslPolicies.Insert(project, sslPolicy).Do()
op, err := config.clientCompute.SslPolicies.Insert(project, sslPolicy).Do()
if err != nil {
return fmt.Errorf("Error creating SSL Policy: %s", err)
}
Expand All @@ -154,7 +154,7 @@ func resourceComputeSslPolicyRead(d *schema.ResourceData, meta interface{}) erro

name := d.Id()

sslPolicy, err := config.clientComputeBeta.SslPolicies.Get(project, name).Do()
sslPolicy, err := config.clientCompute.SslPolicies.Get(project, name).Do()
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("SSL Policy %q", name))
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) er

name := d.Get("name").(string)

sslPolicy := &computeBeta.SslPolicy{
sslPolicy := &compute.SslPolicy{
Fingerprint: d.Get("fingerprint").(string),
Profile: d.Get("profile").(string),
MinTlsVersion: d.Get("min_tls_version").(string),
Expand All @@ -199,7 +199,7 @@ func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) er
}
}

op, err := config.clientComputeBeta.SslPolicies.Patch(project, name, sslPolicy).Do()
op, err := config.clientCompute.SslPolicies.Patch(project, name, sslPolicy).Do()
if err != nil {
return fmt.Errorf("Error updating SSL Policy: %s", err)
}
Expand All @@ -223,7 +223,7 @@ func resourceComputeSslPolicyDelete(d *schema.ResourceData, meta interface{}) er

name := d.Get("name").(string)

op, err := config.clientComputeBeta.SslPolicies.Delete(project, name).Do()
op, err := config.clientCompute.SslPolicies.Delete(project, name).Do()
if err != nil {
return fmt.Errorf("Error deleting SSL Policy: %s", err)
}
Expand Down
22 changes: 11 additions & 11 deletions google/resource_compute_ssl_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
computeBeta "google.golang.org/api/compute/v0.beta"
compute "google.golang.org/api/compute/v1"
)

func TestAccComputeSslPolicy_basic(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -45,7 +45,7 @@ func TestAccComputeSslPolicy_basic(t *testing.T) {
func TestAccComputeSslPolicy_profile(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestAccComputeSslPolicy_profile(t *testing.T) {
func TestAccComputeSslPolicy_update(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestAccComputeSslPolicy_update(t *testing.T) {
func TestAccComputeSslPolicy_tls_version(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestAccComputeSslPolicy_tls_version(t *testing.T) {
func TestAccComputeSslPolicy_custom(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestAccComputeSslPolicy_custom(t *testing.T) {
func TestAccComputeSslPolicy_update_to_custom(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestAccComputeSslPolicy_update_to_custom(t *testing.T) {
func TestAccComputeSslPolicy_update_from_custom(t *testing.T) {
t.Parallel()

var sslPolicy computeBeta.SslPolicy
var sslPolicy compute.SslPolicy
sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -272,7 +272,7 @@ func TestAccComputeSslPolicy_update_from_custom(t *testing.T) {
})
}

func testAccCheckComputeSslPolicyExists(n string, sslPolicy *computeBeta.SslPolicy) resource.TestCheckFunc {
func testAccCheckComputeSslPolicyExists(n string, sslPolicy *compute.SslPolicy) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
Expand All @@ -292,7 +292,7 @@ func testAccCheckComputeSslPolicyExists(n string, sslPolicy *computeBeta.SslPoli

name := rs.Primary.Attributes["name"]

found, err := config.clientComputeBeta.SslPolicies.Get(
found, err := config.clientCompute.SslPolicies.Get(
project, name).Do()
if err != nil {
return fmt.Errorf("Error Reading SSL Policy %s: %s", name, err)
Expand All @@ -316,7 +316,7 @@ func testAccCheckComputeSslPolicyDestroy(s *terraform.State) error {
continue
}

_, err := config.clientComputeBeta.SslPolicies.Get(
_, err := config.clientCompute.SslPolicies.Get(
config.Project, rs.Primary.ID).Do()
if err == nil {
return fmt.Errorf("SSL Policy still exists")
Expand Down
Loading