Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow namespace to be inferred from project #5094

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions google/iam_cloud_run_service_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = ""
}

template {
spec {
containers {
Expand Down Expand Up @@ -151,10 +147,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = ""
}

template {
spec {
containers {
Expand Down Expand Up @@ -191,10 +183,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = ""
}

template {
spec {
containers {
Expand Down Expand Up @@ -225,10 +213,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = ""
}

template {
spec {
containers {
Expand Down
140 changes: 72 additions & 68 deletions google/resource_cloud_run_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
12 changes: 0 additions & 12 deletions google/resource_cloud_run_service_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = ""
}

template {
spec {
containers {
Expand Down Expand Up @@ -106,10 +102,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = "%{project}"
}

template {
spec {
containers {
Expand Down Expand Up @@ -168,10 +160,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun%{random_suffix}"
location = "us-central1"

metadata {
namespace = "%{project}"
}

template {
spec {
containers {
Expand Down
72 changes: 30 additions & 42 deletions website/docs/r/cloud_run_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun"
location = "us-central1"

metadata {
namespace = ""
}

template {
spec {
containers {
Expand Down Expand Up @@ -88,10 +84,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun"
location = "us-central1"

metadata {
namespace = "my-project-name"
}

template {
spec {
containers {
Expand Down Expand Up @@ -130,10 +122,6 @@ resource "google_cloud_run_service" "default" {
name = "tftest-cloudrun"
location = "us-central1"

metadata {
namespace = "my-project-name"
}

template {
spec {
containers {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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` -
Expand Down Expand Up @@ -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:
Expand Down