Skip to content

Commit

Permalink
Merge pull request hashicorp#113 from rileykarson/merge-tpg
Browse files Browse the repository at this point in the history
Merge terraform-provider-google master into tpgb master
  • Loading branch information
rileykarson authored Nov 9, 2018
2 parents 2b5eb99 + 0c13b20 commit 0a99a51
Show file tree
Hide file tree
Showing 78 changed files with 1,637 additions and 317 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.19.1 (Unreleased)

BUG FIXES:
* all: fix deprecation links in resources ([#2197](https://github.com/terraform-providers/terraform-provider-google/issues/2197)] [[#2196](https://github.com/terraform-providers/terraform-provider-google/issues/2196))
* all: fix panics caused by including empty blocks with lists ([#2229](https://github.com/terraform-providers/terraform-provider-google/issues/2229)] [[#2233](https://github.com/terraform-providers/terraform-provider-google/issues/2233)] [[#2239](https://github.com/terraform-providers/terraform-provider-google/issues/2239))
* compute: allow instance templates to have disks with no source image set ([#2218](https://github.com/terraform-providers/terraform-provider-google/issues/2218))
* project: fix plan output when app engine api is not enabled ([#2204](https://github.com/terraform-providers/terraform-provider-google/issues/2204))

## 1.19.0 (October 05, 2018)

BACKWARDS INCOMPATIBILITIES:
Expand All @@ -8,6 +16,7 @@ BACKWARDS INCOMPATIBILITIES:
* compute: `google_compute_instance_group_manager` and `google_compute_region_instance_group_manager` have had their `instance_template` field removed. Use `versions.instance_template` instead. ([#1](https://github.com/terraform-providers/terraform-provider-google/issues/1))
* container: `google_container_cluster`'s `private_cluster` field is now deprecated in favor of `private_cluster_config`. ([#3](https://github.com/terraform-providers/terraform-provider-google/issues/3))
* project: `google_project`'s `app_engine` sub-block has been deprecated. Please use the `google_app_engine_app` resource instead. Changing between the two should not force project re-creation. (#2147)[https://github.com/terraform-providers/terraform-provider-google/pull/2147]
* project: `google_project_iam_policy`'s `restore_policy` field is now deprecated ([#2186](https://github.com/terraform-providers/terraform-provider-google/issues/2186))

FEATURES:
* **New Datasource**: `google_compute_instance` ([#1906](https://github.com/terraform-providers/terraform-provider-google/issues/1906))
Expand Down
2 changes: 1 addition & 1 deletion google-beta/resource_binaryauthorization_attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func expandBinaryAuthorizationAttestorDescription(v interface{}, d *schema.Resou

func expandBinaryAuthorizationAttestorAttestationAuthorityNote(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
2 changes: 1 addition & 1 deletion google-beta/resource_binaryauthorization_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func expandBinaryAuthorizationPolicyClusterAdmissionRulesEnforcementMode(v inter

func expandBinaryAuthorizationPolicyDefaultAdmissionRule(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
35 changes: 16 additions & 19 deletions google-beta/resource_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,28 +586,25 @@ func resourceCloudFunctionsDestroy(d *schema.ResourceData, meta interface{}) err
}

func expandEventTrigger(configured []interface{}, project string) *cloudfunctions.EventTrigger {
if len(configured) == 0 {
if len(configured) == 0 || configured[0] == nil {
return nil
}

if data, ok := configured[0].(map[string]interface{}); ok {
eventType := data["event_type"].(string)
shape := ""
switch {
case strings.HasPrefix(eventType, "providers/cloud.storage/eventTypes/"):
shape = "projects/%s/buckets/%s"
case strings.HasPrefix(eventType, "providers/cloud.pubsub/eventTypes/"):
shape = "projects/%s/topics/%s"
}

return &cloudfunctions.EventTrigger{
EventType: eventType,
Resource: fmt.Sprintf(shape, project, data["resource"].(string)),
FailurePolicy: expandFailurePolicy(data["failure_policy"].([]interface{})),
}
data := configured[0].(map[string]interface{})
eventType := data["event_type"].(string)
shape := ""
switch {
case strings.HasPrefix(eventType, "providers/cloud.storage/eventTypes/"):
shape = "projects/%s/buckets/%s"
case strings.HasPrefix(eventType, "providers/cloud.pubsub/eventTypes/"):
shape = "projects/%s/topics/%s"
}

return nil
return &cloudfunctions.EventTrigger{
EventType: eventType,
Resource: fmt.Sprintf(shape, project, data["resource"].(string)),
FailurePolicy: expandFailurePolicy(data["failure_policy"].([]interface{})),
}
}

func flattenEventTrigger(eventTrigger *cloudfunctions.EventTrigger) []map[string]interface{} {
Expand All @@ -626,11 +623,11 @@ func flattenEventTrigger(eventTrigger *cloudfunctions.EventTrigger) []map[string
}

func expandFailurePolicy(configured []interface{}) *cloudfunctions.FailurePolicy {
if len(configured) == 0 {
if len(configured) == 0 || configured[0] == nil {
return &cloudfunctions.FailurePolicy{}
}

if data, ok := configured[0].(map[string]interface{}); ok && data["retry"].(bool) {
if data := configured[0].(map[string]interface{}); data["retry"].(bool) {
return &cloudfunctions.FailurePolicy{
Retry: &cloudfunctions.Retry{},
}
Expand Down
53 changes: 53 additions & 0 deletions google-beta/resource_compute_address_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,56 @@ resource "google_compute_address" "internal_with_subnet_and_address" {
`, val, val, val,
)
}

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

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeAddressDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeAddress_instanceWithIpExample(acctest.RandString(10)),
},
{
ResourceName: "google_compute_address.static",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeAddress_instanceWithIpExample(val string) string {
return fmt.Sprintf(`
resource "google_compute_address" "static" {
name = "ipv4-address-%s"
}
data "google_compute_image" "debian_image" {
family = "debian-9"
project = "debian-cloud"
}
resource "google_compute_instance" "instance_with_ip" {
name = "vm-instance-%s"
machine_type = "f1-micro"
zone = "us-central1-a"
boot_disk {
initialize_params{
image = "${data.google_compute_image.debian_image.self_link}"
}
}
network_interface {
network = "default"
access_config {
nat_ip = "${google_compute_address.static.address}"
}
}
}
`, val, val,
)
}
6 changes: 3 additions & 3 deletions google-beta/resource_compute_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func expandComputeAutoscalerDescription(v interface{}, d *schema.ResourceData, c

func expandComputeAutoscalerAutoscalingPolicy(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -604,7 +604,7 @@ func expandComputeAutoscalerAutoscalingPolicyCooldownPeriod(v interface{}, d *sc

func expandComputeAutoscalerAutoscalingPolicyCpuUtilization(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -675,7 +675,7 @@ func expandComputeAutoscalerAutoscalingPolicyMetricType(v interface{}, d *schema

func expandComputeAutoscalerAutoscalingPolicyLoadBalancingUtilization(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
22 changes: 10 additions & 12 deletions google-beta/resource_compute_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,17 @@ func resourceComputeBackendServiceDelete(d *schema.ResourceData, meta interface{
}

func expandIap(configured []interface{}) *computeBeta.BackendServiceIAP {
if len(configured) == 0 {
if len(configured) == 0 || configured[0] == nil {
return nil
}
if data, ok := configured[0].(map[string]interface{}); ok {
return &computeBeta.BackendServiceIAP{
Enabled: true,
Oauth2ClientId: data["oauth2_client_id"].(string),
Oauth2ClientSecret: data["oauth2_client_secret"].(string),
ForceSendFields: []string{"Enabled", "Oauth2ClientId", "Oauth2ClientSecret"},
}
}

return nil
data := configured[0].(map[string]interface{})
return &computeBeta.BackendServiceIAP{
Enabled: true,
Oauth2ClientId: data["oauth2_client_id"].(string),
Oauth2ClientSecret: data["oauth2_client_secret"].(string),
ForceSendFields: []string{"Enabled", "Oauth2ClientId", "Oauth2ClientSecret"},
}
}

func flattenIap(iap *computeBeta.BackendServiceIAP) []map[string]interface{} {
Expand Down Expand Up @@ -590,11 +588,11 @@ func expandBackendService(d *schema.ResourceData) (*computeBeta.BackendService,
}

func expandCdnPolicy(configured []interface{}) *computeBeta.BackendServiceCdnPolicy {
if len(configured) == 0 {
if len(configured) == 0 || configured[0] == nil {
return nil
}
data := configured[0].(map[string]interface{})

data := configured[0].(map[string]interface{})
ckp := data["cache_key_policy"].([]interface{})
if len(ckp) == 0 {
return nil
Expand Down
4 changes: 2 additions & 2 deletions google-beta/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ func expandComputeDiskZone(v interface{}, d *schema.ResourceData, config *Config

func expandComputeDiskSourceImageEncryptionKey(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -1101,7 +1101,7 @@ func expandComputeDiskSnapshot(v interface{}, d *schema.ResourceData, config *Co

func expandComputeDiskSourceSnapshotEncryptionKey(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
8 changes: 4 additions & 4 deletions google-beta/resource_compute_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ func expandComputeHealthCheckUnhealthyThreshold(v interface{}, d *schema.Resourc

func expandComputeHealthCheckHttpHealthCheck(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -830,7 +830,7 @@ func expandComputeHealthCheckHttpHealthCheckProxyHeader(v interface{}, d *schema

func expandComputeHealthCheckHttpsHealthCheck(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -886,7 +886,7 @@ func expandComputeHealthCheckHttpsHealthCheckProxyHeader(v interface{}, d *schem

func expandComputeHealthCheckTcpHealthCheck(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -942,7 +942,7 @@ func expandComputeHealthCheckTcpHealthCheckProxyHeader(v interface{}, d *schema.

func expandComputeHealthCheckSslHealthCheck(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
20 changes: 12 additions & 8 deletions google-beta/resource_compute_instance_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,19 @@ func flattenDisks(disks []*computeBeta.AttachedDisk, d *schema.ResourceData, def
for _, disk := range disks {
diskMap := make(map[string]interface{})
if disk.InitializeParams != nil {
selfLink, err := resolvedImageSelfLink(defaultProject, disk.InitializeParams.SourceImage)
if err != nil {
return nil, errwrap.Wrapf("Error expanding source image input to self_link: {{err}}", err)
}
path, err := getRelativePath(selfLink)
if err != nil {
return nil, errwrap.Wrapf("Error getting relative path for source image: {{err}}", err)
if disk.InitializeParams.SourceImage != "" {
selfLink, err := resolvedImageSelfLink(defaultProject, disk.InitializeParams.SourceImage)
if err != nil {
return nil, errwrap.Wrapf("Error expanding source image input to self_link: {{err}}", err)
}
path, err := getRelativePath(selfLink)
if err != nil {
return nil, errwrap.Wrapf("Error getting relative path for source image: {{err}}", err)
}
diskMap["source_image"] = path
} else {
diskMap["source_image"] = ""
}
diskMap["source_image"] = path
diskMap["disk_type"] = disk.InitializeParams.DiskType
diskMap["disk_name"] = disk.InitializeParams.DiskName
diskMap["disk_size_gb"] = disk.InitializeParams.DiskSizeGb
Expand Down
6 changes: 3 additions & 3 deletions google-beta/resource_compute_region_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func expandComputeRegionAutoscalerDescription(v interface{}, d *schema.ResourceD

func expandComputeRegionAutoscalerAutoscalingPolicy(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -600,7 +600,7 @@ func expandComputeRegionAutoscalerAutoscalingPolicyCooldownPeriod(v interface{},

func expandComputeRegionAutoscalerAutoscalingPolicyCpuUtilization(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -671,7 +671,7 @@ func expandComputeRegionAutoscalerAutoscalingPolicyMetricType(v interface{}, d *

func expandComputeRegionAutoscalerAutoscalingPolicyLoadBalancingUtilization(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
4 changes: 2 additions & 2 deletions google-beta/resource_compute_region_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ func expandComputeRegionDiskRegion(v interface{}, d *schema.ResourceData, config

func expandComputeRegionDiskDiskEncryptionKey(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down Expand Up @@ -775,7 +775,7 @@ func expandComputeRegionDiskSnapshot(v interface{}, d *schema.ResourceData, conf

func expandComputeRegionDiskSourceSnapshotEncryptionKey(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
2 changes: 1 addition & 1 deletion google-beta/resource_compute_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func expandComputeRouterNetwork(v interface{}, d *schema.ResourceData, config *C

func expandComputeRouterBgp(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
Expand Down
6 changes: 4 additions & 2 deletions google-beta/resource_compute_security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,10 @@ func expandSecurityPolicyRule(raw interface{}) *compute.SecurityPolicyRule {
}

func expandSecurityPolicyMatch(configured []interface{}) *compute.SecurityPolicyRuleMatcher {
if len(configured) == 0 {
if len(configured) == 0 || configured[0] == nil {
return nil
}

data := configured[0].(map[string]interface{})
return &compute.SecurityPolicyRuleMatcher{
VersionedExpr: data["versioned_expr"].(string),
Expand All @@ -328,9 +329,10 @@ func expandSecurityPolicyMatch(configured []interface{}) *compute.SecurityPolicy
}

func expandSecurityPolicyMatchConfig(configured []interface{}) *compute.SecurityPolicyRuleMatcherConfig {
if len(configured) == 0 {
if len(configured) == 0 || configured[0] == nil {
return nil
}

data := configured[0].(map[string]interface{})
return &compute.SecurityPolicyRuleMatcherConfig{
SrcIpRanges: convertStringArr(data["src_ip_ranges"].(*schema.Set).List()),
Expand Down
Loading

0 comments on commit 0a99a51

Please sign in to comment.