Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#139 from modular-magician/code…
Browse files Browse the repository at this point in the history
…gen-pr-920

Ignore empty json objects inside arrays
  • Loading branch information
chrisst authored Nov 19, 2018
2 parents ea70212 + 707dd95 commit 008a505
Show file tree
Hide file tree
Showing 17 changed files with 159 additions and 0 deletions.
7 changes: 7 additions & 0 deletions google-beta/resource_binaryauthorization_attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ func flattenBinaryAuthorizationAttestorAttestationAuthorityNote(v interface{}) i
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["note_reference"] =
flattenBinaryAuthorizationAttestorAttestationAuthorityNoteNoteReference(original["noteReference"])
Expand All @@ -280,6 +283,10 @@ func flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeys(v inte
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"comment": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysComment(original["comment"]),
"id": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysId(original["id"]),
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_binaryauthorization_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ func flattenBinaryAuthorizationPolicyAdmissionWhitelistPatterns(v interface{}) i
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"name_pattern": flattenBinaryAuthorizationPolicyAdmissionWhitelistPatternsNamePattern(original["namePattern"]),
})
Expand Down Expand Up @@ -379,6 +383,9 @@ func flattenBinaryAuthorizationPolicyDefaultAdmissionRule(v interface{}) interfa
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["evaluation_mode"] =
flattenBinaryAuthorizationPolicyDefaultAdmissionRuleEvaluationMode(original["evaluationMode"])
Expand Down
13 changes: 13 additions & 0 deletions google-beta/resource_compute_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ func flattenComputeAutoscalerAutoscalingPolicy(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["min_replicas"] =
flattenComputeAutoscalerAutoscalingPolicyMinReplicas(original["minNumReplicas"])
Expand Down Expand Up @@ -467,6 +470,9 @@ func flattenComputeAutoscalerAutoscalingPolicyCpuUtilization(v interface{}) inte
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["target"] =
flattenComputeAutoscalerAutoscalingPolicyCpuUtilizationTarget(original["utilizationTarget"])
Expand All @@ -484,6 +490,10 @@ func flattenComputeAutoscalerAutoscalingPolicyMetric(v interface{}) interface{}
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"name": flattenComputeAutoscalerAutoscalingPolicyMetricName(original["metric"]),
"target": flattenComputeAutoscalerAutoscalingPolicyMetricTarget(original["utilizationTarget"]),
Expand Down Expand Up @@ -514,6 +524,9 @@ func flattenComputeAutoscalerAutoscalingPolicyLoadBalancingUtilization(v interfa
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["target"] =
flattenComputeAutoscalerAutoscalingPolicyLoadBalancingUtilizationTarget(original["utilizationTarget"])
Expand Down
9 changes: 9 additions & 0 deletions google-beta/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,9 @@ func flattenComputeDiskSourceImageEncryptionKey(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["raw_key"] =
flattenComputeDiskSourceImageEncryptionKeyRawKey(original["rawKey"])
Expand Down Expand Up @@ -961,6 +964,9 @@ func flattenComputeDiskDiskEncryptionKey(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["raw_key"] =
flattenComputeDiskDiskEncryptionKeyRawKey(original["rawKey"])
Expand Down Expand Up @@ -994,6 +1000,9 @@ func flattenComputeDiskSourceSnapshotEncryptionKey(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["raw_key"] =
flattenComputeDiskSourceSnapshotEncryptionKeyRawKey(original["rawKey"])
Expand Down
8 changes: 8 additions & 0 deletions google-beta/resource_compute_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ func flattenComputeFirewallAllow(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"protocol": flattenComputeFirewallAllowProtocol(original["IPProtocol"]),
"ports": flattenComputeFirewallAllowPorts(original["ports"]),
Expand Down Expand Up @@ -639,6 +643,10 @@ func flattenComputeFirewallDeny(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"protocol": flattenComputeFirewallDenyProtocol(original["IPProtocol"]),
"ports": flattenComputeFirewallDenyPorts(original["ports"]),
Expand Down
12 changes: 12 additions & 0 deletions google-beta/resource_compute_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ func flattenComputeHealthCheckHttpHealthCheck(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["host"] =
flattenComputeHealthCheckHttpHealthCheckHost(original["host"])
Expand Down Expand Up @@ -639,6 +642,9 @@ func flattenComputeHealthCheckHttpsHealthCheck(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["host"] =
flattenComputeHealthCheckHttpsHealthCheckHost(original["host"])
Expand Down Expand Up @@ -677,6 +683,9 @@ func flattenComputeHealthCheckTcpHealthCheck(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["request"] =
flattenComputeHealthCheckTcpHealthCheckRequest(original["request"])
Expand Down Expand Up @@ -715,6 +724,9 @@ func flattenComputeHealthCheckSslHealthCheck(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["request"] =
flattenComputeHealthCheckSslHealthCheckRequest(original["request"])
Expand Down
3 changes: 3 additions & 0 deletions google-beta/resource_compute_interconnect_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ func flattenComputeInterconnectAttachmentPrivateInterconnectInfo(v interface{})
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["tag8021q"] =
flattenComputeInterconnectAttachmentPrivateInterconnectInfoTag8021q(original["tag8021q"])
Expand Down
13 changes: 13 additions & 0 deletions google-beta/resource_compute_region_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ func flattenComputeRegionAutoscalerAutoscalingPolicy(v interface{}) interface{}
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["min_replicas"] =
flattenComputeRegionAutoscalerAutoscalingPolicyMinReplicas(original["minNumReplicas"])
Expand Down Expand Up @@ -466,6 +469,9 @@ func flattenComputeRegionAutoscalerAutoscalingPolicyCpuUtilization(v interface{}
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["target"] =
flattenComputeRegionAutoscalerAutoscalingPolicyCpuUtilizationTarget(original["utilizationTarget"])
Expand All @@ -483,6 +489,10 @@ func flattenComputeRegionAutoscalerAutoscalingPolicyMetric(v interface{}) interf
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"name": flattenComputeRegionAutoscalerAutoscalingPolicyMetricName(original["metric"]),
"target": flattenComputeRegionAutoscalerAutoscalingPolicyMetricTarget(original["utilizationTarget"]),
Expand Down Expand Up @@ -513,6 +523,9 @@ func flattenComputeRegionAutoscalerAutoscalingPolicyLoadBalancingUtilization(v i
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["target"] =
flattenComputeRegionAutoscalerAutoscalingPolicyLoadBalancingUtilizationTarget(original["utilizationTarget"])
Expand Down
6 changes: 6 additions & 0 deletions google-beta/resource_compute_region_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ func flattenComputeRegionDiskDiskEncryptionKey(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["raw_key"] =
flattenComputeRegionDiskDiskEncryptionKeyRawKey(original["rawKey"])
Expand Down Expand Up @@ -686,6 +689,9 @@ func flattenComputeRegionDiskSourceSnapshotEncryptionKey(v interface{}) interfac
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["raw_key"] =
flattenComputeRegionDiskSourceSnapshotEncryptionKeyRawKey(original["rawKey"])
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ func flattenComputeRouterBgp(v interface{}) interface{} {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["asn"] =
flattenComputeRouterBgpAsn(original["asn"])
Expand Down Expand Up @@ -433,6 +436,10 @@ func flattenComputeRouterBgpAdvertisedIpRanges(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"range": flattenComputeRouterBgpAdvertisedIpRangesRange(original["range"]),
"description": flattenComputeRouterBgpAdvertisedIpRangesDescription(original["description"]),
Expand Down
4 changes: 4 additions & 0 deletions google-beta/resource_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ func flattenComputeSubnetworkSecondaryIpRange(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"range_name": flattenComputeSubnetworkSecondaryIpRangeRangeName(original["rangeName"]),
"ip_cidr_range": flattenComputeSubnetworkSecondaryIpRangeIpCidrRange(original["ipCidrRange"]),
Expand Down
16 changes: 16 additions & 0 deletions google-beta/resource_compute_url_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ func flattenComputeUrlMapHost_rule(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"description": flattenComputeUrlMapHost_ruleDescription(original["description"]),
"hosts": flattenComputeUrlMapHost_ruleHosts(original["hosts"]),
Expand Down Expand Up @@ -522,6 +526,10 @@ func flattenComputeUrlMapPath_matcher(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"default_service": flattenComputeUrlMapPath_matcherDefaultService(original["defaultService"]),
"description": flattenComputeUrlMapPath_matcherDescription(original["description"]),
Expand Down Expand Up @@ -554,6 +562,10 @@ func flattenComputeUrlMapPath_matcherPath_rule(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"paths": flattenComputeUrlMapPath_matcherPath_rulePaths(original["paths"]),
"service": flattenComputeUrlMapPath_matcherPath_ruleService(original["service"]),
Expand Down Expand Up @@ -583,6 +595,10 @@ func flattenComputeUrlMapTest(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"description": flattenComputeUrlMapTestDescription(original["description"]),
"host": flattenComputeUrlMapTestHost(original["host"]),
Expand Down
6 changes: 6 additions & 0 deletions google-beta/resource_containeranalysis_note.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func flattenContainerAnalysisNoteAttestationAuthority(v interface{}) interface{}
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["hint"] =
flattenContainerAnalysisNoteAttestationAuthorityHint(original["hint"])
Expand All @@ -233,6 +236,9 @@ func flattenContainerAnalysisNoteAttestationAuthorityHint(v interface{}) interfa
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["human_readable_name"] =
flattenContainerAnalysisNoteAttestationAuthorityHintHumanReadableName(original["humanReadableName"])
Expand Down
8 changes: 8 additions & 0 deletions google-beta/resource_filestore_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ func flattenFilestoreInstanceFileShares(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"name": flattenFilestoreInstanceFileSharesName(original["name"]),
"capacity_gb": flattenFilestoreInstanceFileSharesCapacityGb(original["capacityGb"]),
Expand Down Expand Up @@ -452,6 +456,10 @@ func flattenFilestoreInstanceNetworks(v interface{}) interface{} {
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"network": flattenFilestoreInstanceNetworksNetwork(original["network"]),
"modes": flattenFilestoreInstanceNetworksModes(original["modes"]),
Expand Down
Loading

0 comments on commit 008a505

Please sign in to comment.