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

Adds grpc field to startup_probe and liveness_probe in google_cloud_run_service beta resource #6781

Merged
merged 2 commits into from
Nov 9, 2022
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
46 changes: 46 additions & 0 deletions mmv1/products/cloudrun/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ objects:
exactly_one_of:
- template.0.spec.0.containers.0.startup_probe.0.tcp_socket
- template.0.spec.0.containers.0.startup_probe.0.http_get
- template.0.spec.0.containers.0.startup_probe.0.grpc
send_empty_value: true
allow_empty_object: true
properties:
Expand All @@ -673,6 +674,7 @@ objects:
exactly_one_of:
- template.0.spec.0.containers.0.startup_probe.0.tcp_socket
- template.0.spec.0.containers.0.startup_probe.0.http_get
- template.0.spec.0.containers.0.startup_probe.0.grpc
send_empty_value: true
allow_empty_object: true
properties:
Expand All @@ -698,6 +700,27 @@ objects:
The header field value.
default_value: ""
send_empty_value: true
- !ruby/object:Api::Type::NestedObject
name: grpc
description: |-
GRPC specifies an action involving a GRPC port.
exactly_one_of:
- template.0.spec.0.containers.0.startup_probe.0.tcp_socket
- template.0.spec.0.containers.0.startup_probe.0.http_get
- template.0.spec.0.containers.0.startup_probe.0.grpc
send_empty_value: true
allow_empty_object: true
properties:
- !ruby/object:Api::Type::Integer
name: port
description: |-
Port number to access on the container. Number must be in the range 1 to 65535.
- !ruby/object:Api::Type::String
name: service
description: |-
The name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
If this is not specified, the default behavior is defined by gRPC.
- !ruby/object:Api::Type::NestedObject
name: livenessProbe
min_version: beta
Expand Down Expand Up @@ -735,6 +758,9 @@ objects:
name: httpGet
description: |-
HttpGet specifies the http request to perform.
exactly_one_of:
- template.0.spec.0.containers.0.liveness_probe.0.http_get
- template.0.spec.0.containers.0.liveness_probe.0.grpc
send_empty_value: true
allow_empty_object: true
properties:
Expand All @@ -760,6 +786,26 @@ objects:
The header field value.
default_value: ""
send_empty_value: true
- !ruby/object:Api::Type::NestedObject
name: grpc
description: |-
GRPC specifies an action involving a GRPC port.
exactly_one_of:
- template.0.spec.0.containers.0.liveness_probe.0.http_get
- template.0.spec.0.containers.0.liveness_probe.0.grpc
send_empty_value: true
allow_empty_object: true
properties:
- !ruby/object:Api::Type::Integer
name: port
description: |-
Port number to access on the container. Number must be in the range 1 to 65535.
- !ruby/object:Api::Type::String
name: service
description: |-
The name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
If this is not specified, the default behavior is defined by gRPC.

- !ruby/object:Api::Type::Integer
name: containerConcurrency
Expand Down
6 changes: 6 additions & 0 deletions mmv1/products/cloudrun/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides
spec.template.spec.containers.startupProbe.tcpSocket.port: !ruby/object:Overrides::Terraform::PropertyOverride
# when port is not specified, container.ports[0].port is a possible default value
default_from_api: true
spec.template.spec.containers.startupProbe.grpc.port: !ruby/object:Overrides::Terraform::PropertyOverride
# when port is not specified, container.ports[0].port is a possible default value
default_from_api: true
spec.template.spec.containers.livenessProbe.grpc.port: !ruby/object:Overrides::Terraform::PropertyOverride
# when port is not specified, container.ports[0].port is a possible default value
default_from_api: true
# Terraform autofills the only required field in metadata
metadata: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,24 @@ func TestAccCloudRunService_probes(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "status.0.conditions"},
},
{
Config: testAccCloudRunService_cloudRunServiceUpdateWithEmptyGRPCLivenessProbe(name, project),
},
{
ResourceName: "google_cloud_run_service.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "status.0.conditions"},
},
{
Config: testAccCloudRunService_cloudRunServiceUpdateWithGRPCLivenessProbe(name, project),
},
{
ResourceName: "google_cloud_run_service.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "status.0.conditions"},
},
},
})
}
Expand Down Expand Up @@ -588,4 +606,75 @@ resource "google_cloud_run_service" "default" {
`, name, project)
}

func testAccCloudRunService_cloudRunServiceUpdateWithEmptyGRPCLivenessProbe(name, project string) string {
return fmt.Sprintf(`
resource "google_cloud_run_service" "default" {
name = "%s"
location = "us-central1"

metadata {
namespace = "%s"
annotations = {
generated-by = "magic-modules"
"run.googleapis.com/launch-stage" = "BETA"
}
}

template {
spec {
containers {
image = "gcr.io/cloudrun/hello"
liveness_probe {
grpc {}
}
}
}
}

lifecycle {
ignore_changes = [
metadata.0.annotations,
]
}
}
`, name, project)
}

func testAccCloudRunService_cloudRunServiceUpdateWithGRPCLivenessProbe(name, project string) string {
return fmt.Sprintf(`
resource "google_cloud_run_service" "default" {
name = "%s"
location = "us-central1"

metadata {
namespace = "%s"
annotations = {
generated-by = "magic-modules"
"run.googleapis.com/launch-stage" = "BETA"
}
}

template {
spec {
containers {
image = "gcr.io/cloudrun/hello"
liveness_probe {
grpc {
port = 8080
service = "health"
}
}
}
}
}

lifecycle {
ignore_changes = [
metadata.0.annotations,
]
}
}
`, name, project)
}

<% end -%>