Skip to content

Commit

Permalink
Docs fixes, swapping out ForceNews.
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson committed Jan 18, 2019
1 parent 1cf1890 commit e366604
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 74 deletions.
34 changes: 8 additions & 26 deletions products/spanner/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ objects:
name: 'config'
resource: 'InstanceConfig'
imports: 'name'
description: 'A reference to the instance configuration.'
description: |
The name of the instance's configuration (similar but not
quite the same as a region) which defines defines the geographic placement and
replication of your databases in this instance. It determines where your data
is stored. Values are typically of the form `regional-europe-west1` , `us-central` etc.
In order to obtain a valid list please consult the
[Configuration section of the docs](https://cloud.google.com/spanner/docs/instances).
required: true
- !ruby/object:Api::Type::String
name: 'displayName'
Expand All @@ -85,34 +91,10 @@ objects:
- !ruby/object:Api::Type::Integer
name: 'nodeCount'
description: 'The number of nodes allocated to this instance.'
required: true
default_value: 1
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: |
Cloud Labels are a flexible and lightweight mechanism for organizing
cloud resources into groups that reflect a customer's organizational
needs and deployment strategies. Cloud Labels can be used to filter
collections of resources. They can be used to control how resource
metrics are aggregated. And they can be used as arguments to policy
management rules (e.g. route, firewall, load balancing, etc.).
Label keys must be between 1 and 63 characters long and must conform
to the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
Label values must be between 0 and 63 characters long and must conform
to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
No more than 64 labels can be associated with a given resource.
See https://goo.gl/xmQnxf for more information on and examples of
labels.
If you plan to use labels in your own code, please note that
additional characters may be allowed in the future. And so you are
advised to use an internal label representation, such as JSON, which
doesn't rely upon specific characters being disallowed. For example,
representing labels as the string: name + "_" + value would prove
problematic if we were to allow "_" in a future release.
An object containing a list of "key": value pairs.
Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
- !ruby/object:Api::Type::Enum
Expand Down
11 changes: 10 additions & 1 deletion products/spanner/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,19 @@ overrides: !ruby/object:Overrides::ResourceOverrides
- "projects/{{project}}/instances/{{name}}"
- "{{project}}/{{name}}"
- "{{name}}"
examples:
- !ruby/object:Provider::Terraform::Examples
name: "spanner_instance_basic"
primary_resource_id: "example"
version: <%= version_name %>
description: |
{{description}}
If not provided, a random string starting with `tf-` will be selected.
properties:
displayName: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
regex: '^(?:[a-z](?:[-_a-z0-9]{2,28}[a-z0-9])?)$'
regex: '^(?:[a-zA-Z](?:[- _a-zA-Z0-9]{2,28}[a-zA-Z0-9])?)$'
name: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
regex: '^(?:[a-z](?:[-_a-z0-9]{4,28}[a-z0-9])?)$'
Expand Down
8 changes: 8 additions & 0 deletions templates/terraform/examples/spanner_instance_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "google_spanner_instance" "example" {
config = "regional-us-central1"
display_name = "Test Spanner Instance"
num_nodes = 2
labels {
"foo" = "bar"
}
}
5 changes: 3 additions & 2 deletions templates/terraform/post_create/sleep.go.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Spanner instances are, ironically, eventually consistent.
// We ensure that the Read sees the instance as created by sleeping, briefly.
// This is useful if the resource in question doesn't have a perfectly consistent API
// That is, the Operation for Create might return before the Get operation shows the
// completed state of the resource.
time.Sleep(5 * time.Second)
43 changes: 0 additions & 43 deletions third_party/terraform/tests/resource_spanner_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ package google

import (
"fmt"
"net/http"
"testing"

"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"

"google.golang.org/api/googleapi"
)

// Unit Tests
Expand Down Expand Up @@ -131,44 +126,6 @@ func TestAccSpannerInstance_update(t *testing.T) {
})
}

func testAccCheckSpannerInstanceDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)

for _, rs := range s.RootModule().Resources {
if rs.Type != "google_spanner_instance" {
continue
}

if rs.Primary.ID == "" {
return fmt.Errorf("Unable to verify delete of spanner instance, ID is empty")
}

instanceName := rs.Primary.Attributes["name"]
project, err := getTestProject(rs.Primary, config)
if err != nil {
return err
}

id := spannerInstanceId{
Project: project,
Instance: instanceName,
}
_, err = config.clientSpanner.Projects.Instances.Get(
id.instanceUri()).Do()

if err == nil {
return fmt.Errorf("Spanner instance still exists")
}

if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {
return nil
}
return errwrap.Wrapf("Error verifying spanner instance deleted: {{err}}", err)
}

return nil
}

func testAccSpannerInstance_basic(name string) string {
return fmt.Sprintf(`
resource "google_spanner_instance" "basic" {
Expand Down
3 changes: 1 addition & 2 deletions third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
GeneratedRedisResourcesMap,
GeneratedResourceManagerResourcesMap,
GeneratedSourceRepoResourcesMap,
GeneratedSpannerResourcesMap,
GeneratedStorageResourcesMap,
GeneratedMonitoringResourcesMap,
map[string]*schema.Resource{
Expand Down Expand Up @@ -216,11 +217,9 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
<% unless version == 'ga' -%>
"google_service_networking_connection": resourceServiceNetworkingConnection(),
<% end -%>
"google_spanner_instance": resourceSpannerInstance(),
"google_spanner_instance_iam_binding": ResourceIamBindingWithImport(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
"google_spanner_instance_iam_member": ResourceIamMemberWithImport(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
"google_spanner_instance_iam_policy": ResourceIamPolicyWithImport(IamSpannerInstanceSchema, NewSpannerInstanceIamUpdater, SpannerInstanceIdParseFunc),
"google_spanner_database": resourceSpannerDatabase(),
"google_spanner_database_iam_binding": ResourceIamBindingWithImport(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
"google_spanner_database_iam_member": ResourceIamMemberWithImport(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
"google_spanner_database_iam_policy": ResourceIamPolicyWithImport(IamSpannerDatabaseSchema, NewSpannerDatabaseIamUpdater, SpannerDatabaseIdParseFunc),
Expand Down

0 comments on commit e366604

Please sign in to comment.