diff --git a/google/iam_cloud_run_service_generated_test.go b/google/iam_cloud_run_service_generated_test.go index 230a018f23b..17c8b4f6680 100644 --- a/google/iam_cloud_run_service_generated_test.go +++ b/google/iam_cloud_run_service_generated_test.go @@ -117,10 +117,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "" - } - template { spec { containers { @@ -151,10 +147,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "" - } - template { spec { containers { @@ -191,10 +183,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "" - } - template { spec { containers { @@ -225,10 +213,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "" - } - template { spec { containers { diff --git a/google/resource_cloud_run_service.go b/google/resource_cloud_run_service.go index 5767ab9cb74..e4cb59499e1 100644 --- a/google/resource_cloud_run_service.go +++ b/google/resource_cloud_run_service.go @@ -47,73 +47,6 @@ func resourceCloudRunService() *schema.Resource { Required: true, Description: `The location of the cloud run instance. eg us-central1`, }, - "metadata": { - Type: schema.TypeList, - Required: true, - Description: `Metadata associated with this Service, including name, namespace, labels, -and annotations.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "annotations": { - Type: schema.TypeMap, - Computed: true, - Optional: true, - Description: `Annotations is a key value map stored with a resource that -may be set by external tools to store and retrieve arbitrary metadata. More -info: http://kubernetes.io/docs/user-guide/annotations`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "labels": { - Type: schema.TypeMap, - Computed: true, - Optional: true, - Description: `Map of string keys and values that can be used to organize and categorize -(scope and select) objects. May match selectors of replication controllers -and routes. -More info: http://kubernetes.io/docs/user-guide/labels`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "namespace": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `In Cloud Run the namespace must be equal to either the -project ID or project number.`, - }, - "generation": { - Type: schema.TypeInt, - Computed: true, - Description: `A sequence number representing a specific generation of the desired state.`, - }, - "resource_version": { - Type: schema.TypeString, - Computed: true, - Description: `An opaque value that represents the internal version of this object that -can be used by clients to determine when objects have changed. May be used -for optimistic concurrency, change detection, and the watch operation on a -resource or set of resources. They may only be valid for a -particular resource or set of resources. - -More info: -https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - Description: `SelfLink is a URL representing this object.`, - }, - "uid": { - Type: schema.TypeString, - Computed: true, - Description: `UID is a unique id generated by the server on successful creation of a resource and is not -allowed to change on PUT operations. - -More info: http://kubernetes.io/docs/user-guide/identifiers#uids`, - }, - }, - }, - }, "name": { Type: schema.TypeString, Required: true, @@ -423,7 +356,7 @@ More info: http://kubernetes.io/docs/user-guide/identifiers#names`, Computed: true, Optional: true, Description: `In Cloud Run the namespace must be equal to either the -project ID or project number.`, +project ID or project number. It will default to the resource's project.`, }, "generation": { Type: schema.TypeInt, @@ -491,6 +424,74 @@ false when RevisionName is non-empty.`, }, }, + "metadata": { + Type: schema.TypeList, + Computed: true, + Optional: true, + Description: `Metadata associated with this Service, including name, namespace, labels, +and annotations.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "annotations": { + Type: schema.TypeMap, + Computed: true, + Optional: true, + Description: `Annotations is a key value map stored with a resource that +may be set by external tools to store and retrieve arbitrary metadata. More +info: http://kubernetes.io/docs/user-guide/annotations`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "labels": { + Type: schema.TypeMap, + Computed: true, + Optional: true, + Description: `Map of string keys and values that can be used to organize and categorize +(scope and select) objects. May match selectors of replication controllers +and routes. +More info: http://kubernetes.io/docs/user-guide/labels`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "namespace": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: `In Cloud Run the namespace must be equal to either the +project ID or project number.`, + }, + "generation": { + Type: schema.TypeInt, + Computed: true, + Description: `A sequence number representing a specific generation of the desired state.`, + }, + "resource_version": { + Type: schema.TypeString, + Computed: true, + Description: `An opaque value that represents the internal version of this object that +can be used by clients to determine when objects have changed. May be used +for optimistic concurrency, change detection, and the watch operation on a +resource or set of resources. They may only be valid for a +particular resource or set of resources. + +More info: +https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency`, + }, + "self_link": { + Type: schema.TypeString, + Computed: true, + Description: `SelfLink is a URL representing this object.`, + }, + "uid": { + Type: schema.TypeString, + Computed: true, + Description: `UID is a unique id generated by the server on successful creation of a resource and is not +allowed to change on PUT operations. + +More info: http://kubernetes.io/docs/user-guide/identifiers#uids`, + }, + }, + }, + }, "status": { Type: schema.TypeList, Computed: true, @@ -1969,6 +1970,9 @@ func expandCloudRunServiceMetadataAnnotations(v interface{}, d TerraformResource func resourceCloudRunServiceEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { name := d.Get("name").(string) + if obj["metadata"] == nil { + obj["metadata"] = make(map[string]interface{}) + } metadata := obj["metadata"].(map[string]interface{}) metadata["name"] = name diff --git a/google/resource_cloud_run_service_generated_test.go b/google/resource_cloud_run_service_generated_test.go index c9324c4a015..c4f243e98d6 100644 --- a/google/resource_cloud_run_service_generated_test.go +++ b/google/resource_cloud_run_service_generated_test.go @@ -55,10 +55,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "" - } - template { spec { containers { @@ -106,10 +102,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "%{project}" - } - template { spec { containers { @@ -168,10 +160,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun%{random_suffix}" location = "us-central1" - metadata { - namespace = "%{project}" - } - template { spec { containers { diff --git a/website/docs/r/cloud_run_service.html.markdown b/website/docs/r/cloud_run_service.html.markdown index 5906bc25789..bd5cb8ce8b6 100644 --- a/website/docs/r/cloud_run_service.html.markdown +++ b/website/docs/r/cloud_run_service.html.markdown @@ -57,10 +57,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun" location = "us-central1" - metadata { - namespace = "" - } - template { spec { containers { @@ -88,10 +84,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun" location = "us-central1" - metadata { - namespace = "my-project-name" - } - template { spec { containers { @@ -130,10 +122,6 @@ resource "google_cloud_run_service" "default" { name = "tftest-cloudrun" location = "us-central1" - metadata { - namespace = "my-project-name" - } - template { spec { containers { @@ -173,11 +161,6 @@ The following arguments are supported: for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names -* `metadata` - - (Required) - Metadata associated with this Service, including name, namespace, labels, - and annotations. Structure is documented below. - * `location` - (Required) The location of the cloud run instance. eg us-central1 @@ -250,7 +233,7 @@ The `metadata` block supports: * `namespace` - (Optional) In Cloud Run the namespace must be equal to either the - project ID or project number. + project ID or project number. It will default to the resource's project. * `annotations` - (Optional) @@ -441,6 +424,35 @@ The `resources` block supports: The values of the map is string form of the 'quantity' k8s type: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go +- - - + + +* `traffic` - + (Optional) + Traffic specifies how to distribute traffic over a collection of Knative Revisions + and Configurations Structure is documented below. + +* `template` - + (Optional) + template holds the latest specification for the Revision to + be stamped out. The template references the container image, and may also + include labels and annotations that should be attached to the Revision. + To correlate a Revision, and/or to force a Revision to be created when the + spec doesn't otherwise change, a nonce label may be provided in the + template metadata. For more details, see: + https://github.com/knative/serving/blob/master/docs/client-conventions.md#associate-modifications-with-revisions + Cloud Run does not currently support referencing a build that is + responsible for materializing the container image from source. Structure is documented below. + +* `metadata` - + (Optional) + Metadata associated with this Service, including name, namespace, labels, + and annotations. Structure is documented below. + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + + The `metadata` block supports: * `labels` - @@ -481,30 +493,6 @@ The `metadata` block supports: may be set by external tools to store and retrieve arbitrary metadata. More info: http://kubernetes.io/docs/user-guide/annotations -- - - - - -* `traffic` - - (Optional) - Traffic specifies how to distribute traffic over a collection of Knative Revisions - and Configurations Structure is documented below. - -* `template` - - (Optional) - template holds the latest specification for the Revision to - be stamped out. The template references the container image, and may also - include labels and annotations that should be attached to the Revision. - To correlate a Revision, and/or to force a Revision to be created when the - spec doesn't otherwise change, a nonce label may be provided in the - template metadata. For more details, see: - https://github.com/knative/serving/blob/master/docs/client-conventions.md#associate-modifications-with-revisions - Cloud Run does not currently support referencing a build that is - responsible for materializing the container image from source. Structure is documented below. - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the provider project is used. - - ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: