Skip to content

Commit

Permalink
Merge pull request #10 from terraform-providers/catchup-with-ga
Browse files Browse the repository at this point in the history
Catchup with ga
  • Loading branch information
chrisst authored Oct 18, 2018
2 parents 2b5eb99 + 034910f commit 017fcb6
Show file tree
Hide file tree
Showing 69 changed files with 2,984 additions and 1,579 deletions.
7 changes: 0 additions & 7 deletions google-beta/compute_instance_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func flattenNetworkInterfaces(d *schema.ResourceData, config *Config, networkInt
region = subnet.Region

flattened[i] = map[string]interface{}{
"address": iface.NetworkIP,
"network_ip": iface.NetworkIP,
"network": ConvertSelfLinkToV1(iface.Network),
"subnetwork": ConvertSelfLinkToV1(iface.Subnetwork),
Expand Down Expand Up @@ -147,12 +146,6 @@ func expandNetworkInterfaces(d *schema.ResourceData, config *Config) ([]*compute
AliasIpRanges: expandAliasIpRanges(data["alias_ip_range"].([]interface{})),
}

// address is deprecated, but address took priority over networkIP before
// so it should until it's removed.
if data["address"].(string) != "" {
ifaces[i].NetworkIP = data["address"].(string)
}

}
return ifaces, nil
}
Expand Down
2 changes: 0 additions & 2 deletions google-beta/data_source_google_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ resource "google_compute_instance" "foo" {
baz = "qux"
}
create_timeout = 5
metadata {
startup-script = "echo Hello"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func dataSourceGoogleContainerEngineVersions() *schema.Resource {
Optional: true,
},
"region": {
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"zone"},
Expand Down
25 changes: 14 additions & 11 deletions google-beta/iam_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ import (

var IamComputeSubnetworkSchema = map[string]*schema.Schema{
"subnetwork": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
}

Expand Down
23 changes: 10 additions & 13 deletions google-beta/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,15 @@ func BetaMetadataUpdate(oldMDMap map[string]interface{}, newMDMap map[string]int
}
}

// expandComputeMetadata transforms a map representing computing metadata into a list of compute.MetadataItems suitable
// for the GCP client.
func expandComputeMetadata(m map[string]string) []*compute.MetadataItems {
func expandComputeMetadata(m map[string]interface{}) []*compute.MetadataItems {
metadata := make([]*compute.MetadataItems, len(m))

idx := 0
for key, value := range m {
// Make a copy of value as we need a ptr type; if we directly use 'value' then all items will reference the same
// memory address
vtmp := value
metadata[idx] = &compute.MetadataItems{Key: key, Value: &vtmp}
idx++
// Append new metadata to existing metadata
for key, val := range m {
v := val.(string)
metadata = append(metadata, &compute.MetadataItems{
Key: key,
Value: &v,
})
}

return metadata
Expand All @@ -140,8 +137,8 @@ func flattenMetadataBeta(metadata *computeBeta.Metadata) map[string]string {
// compute.metadata rather than computeBeta.metadata as an argument. It should
// be removed in favour of flattenMetadataBeta if/when all resources using it get
// beta support.
func flattenMetadata(metadata *compute.Metadata) map[string]string {
metadataMap := make(map[string]string)
func flattenMetadata(metadata *compute.Metadata) map[string]interface{} {
metadataMap := make(map[string]interface{})
for _, item := range metadata.Items {
metadataMap[item.Key] = *item.Value
}
Expand Down
10 changes: 6 additions & 4 deletions google-beta/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ var schemaNodeConfig = &schema.Schema{
},

"taint": {
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Expand Down Expand Up @@ -169,10 +170,11 @@ var schemaNodeConfig = &schema.Schema{
},

"workload_metadata_config": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_metadata": {
Expand Down
1 change: 1 addition & 0 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func Provider() terraform.ResourceProvider {
GeneratedFilestoreResourcesMap,
GeneratedRedisResourcesMap,
GeneratedResourceManagerResourcesMap,
GeneratedStorageResourcesMap,
GeneratedMonitoringResourcesMap,
map[string]*schema.Resource{
"google_app_engine_application": resourceAppEngineApplication(),
Expand Down
1 change: 1 addition & 0 deletions google-beta/provider_compute_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ var GeneratedComputeResourcesMap = map[string]*schema.Resource{
"google_compute_target_ssl_proxy": resourceComputeTargetSslProxy(),
"google_compute_target_tcp_proxy": resourceComputeTargetTcpProxy(),
"google_compute_vpn_gateway": resourceComputeVpnGateway(),
"google_compute_url_map": resourceComputeUrlMap(),
"google_compute_vpn_tunnel": resourceComputeVpnTunnel(),
}
21 changes: 21 additions & 0 deletions google-beta/provider_storage_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package google

import "github.com/hashicorp/terraform/helper/schema"

var GeneratedStorageResourcesMap = map[string]*schema.Resource{
"google_storage_object_access_control": resourceStorageObjectAccessControl(),
}
28 changes: 28 additions & 0 deletions google-beta/resource_bigtable_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ func resourceBigtableTable() *schema.Resource {
ForceNew: true,
},

"column_family": {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"family": {
Type: schema.TypeString,
Required: true,
},
},
},
},

"instance_name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -79,6 +93,20 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error
}
}

if d.Get("column_family.#").(int) > 0 {
columns := d.Get("column_family").(*schema.Set).List()

for _, co := range columns {
column := co.(map[string]interface{})

if v, ok := column["family"]; ok {
if err := c.CreateColumnFamily(ctx, name, v.(string)); err != nil {
return fmt.Errorf("Error creating column family %s. %s", v, err)
}
}
}
}

d.SetId(name)

return resourceBigtableTableRead(d, meta)
Expand Down
98 changes: 98 additions & 0 deletions google-beta/resource_bigtable_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,52 @@ func TestAccBigtableTable_splitKeys(t *testing.T) {
})
}

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

instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
tableName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
family := fmt.Sprintf("tf-test-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigtableTableDestroy,
Steps: []resource.TestStep{
{
Config: testAccBigtableTable_family(instanceName, tableName, family),
Check: resource.ComposeTestCheckFunc(
testAccBigtableTableExists(
"google_bigtable_table.table"),
),
},
},
})
}

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

instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
tableName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
family := fmt.Sprintf("tf-test-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigtableTableDestroy,
Steps: []resource.TestStep{
{
Config: testAccBigtableTable_familyMany(instanceName, tableName, family),
Check: resource.ComposeTestCheckFunc(
testAccBigtableTableExists(
"google_bigtable_table.table"),
),
},
},
})
}

func testAccCheckBigtableTableDestroy(s *terraform.State) error {
var ctx = context.Background()
for _, rs := range s.RootModule().Resources {
Expand Down Expand Up @@ -139,3 +185,55 @@ resource "google_bigtable_table" "table" {
}
`, instanceName, instanceName, tableName)
}

func testAccBigtableTable_family(instanceName, tableName, family string) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
name = "%s"
cluster {
cluster_id = "%s"
zone = "us-central1-b"
}
instance_type = "DEVELOPMENT"
}
resource "google_bigtable_table" "table" {
name = "%s"
instance_name = "${google_bigtable_instance.instance.name}"
column_family {
family = "%s"
}
}
`, instanceName, instanceName, tableName, family)
}

func testAccBigtableTable_familyMany(instanceName, tableName, family string) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
name = "%s"
cluster {
cluster_id = "%s"
zone = "us-central1-b"
}
instance_type = "DEVELOPMENT"
}
resource "google_bigtable_table" "table" {
name = "%s"
instance_name = "${google_bigtable_instance.instance.name}"
column_family {
family = "%s-first"
}
column_family {
family = "%s-second"
}
}
`, instanceName, instanceName, tableName, family, family)
}
5 changes: 4 additions & 1 deletion google-beta/resource_binaryauthorization_attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ func resourceBinaryAuthorizationAttestor() *schema.Resource {
Importer: &schema.ResourceImporter{
State: resourceBinaryAuthorizationAttestorImport,
},
DeprecationMessage: `This resource is in beta and will be removed from this provider.
Use the BinaryAuthorizationAttestor resource in the terraform-provider-google-beta provider to continue using it.
See https://terraform.io/docs/providers/google/provider_versions.html for more details on beta resources.`,

Schema: map[string]*schema.Schema{
"attestation_authority_note": {
Expand Down Expand Up @@ -314,7 +317,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
5 changes: 4 additions & 1 deletion google-beta/resource_binaryauthorization_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func resourceBinaryAuthorizationPolicy() *schema.Resource {
Importer: &schema.ResourceImporter{
State: resourceBinaryAuthorizationPolicyImport,
},
DeprecationMessage: `This resource is in beta and will be removed from this provider.
Use the BinaryAuthorizationPolicy resource in the terraform-provider-google-beta provider to continue using it.
See https://terraform.io/docs/providers/google/provider_versions.html for more details on beta resources.`,

Schema: map[string]*schema.Schema{
"default_admission_rule": {
Expand Down Expand Up @@ -500,7 +503,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
Loading

0 comments on commit 017fcb6

Please sign in to comment.