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

cloudrunv2: Validate number of ports specified restricting to 1. #7103

Conversation

modular-magician
Copy link
Collaborator

Accidentally specifying the containers.ports twice results in the following error:

Error: Error updating Service "projects/myproject/locations/us-central1/services/myservice": googleapi: Error 400: Violation in UpdateServiceRequest.service.template.containers[0].ports: ports should contain 0 or 1 port.
│ Details:
│ [
│   {
│     "@type": "type.googleapis.com/google.rpc.BadRequest",
│     "fieldViolations": [
│       {
│         "description": "ports should contain 0 or 1 port.",
│         "field": "Violation in UpdateServiceRequest.service.template.containers[0].ports"
│       }
│     ]
│   }
│ ]
│ 
│   with google_cloud_run_v2_service.myservice,
│   on myservice.tf line 1, in resource "google_cloud_run_v2_service" "myservice":
│    1: resource "google_cloud_run_v2_service" "myservice" {
│ 

It would be convenient if this issue could be caught at validation time.

cloudrunv2: added the validation to restrict number of ports to 1 to fail earlier than server-side validation

Derived from GoogleCloudPlatform/magic-modules#10173

…173)

* cloudrunv2: Validate number of ports specified restricting to 1.

* Update mmv1/products/cloudrunv2/Service.yaml

[upstream:219ab589aaafa919c7011967def03305f56c8462]

Signed-off-by: Modular Magician <magic-modules@google.com>
@modular-magician modular-magician merged commit 3d49908 into hashicorp:main Mar 14, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant