Skip to content

Commit 8d436da

Browse files
bskaplanbkap
andauthored
feat: support nfs and gcs in cloudrun and cloudrunv2 GA provider (#11503)
Co-authored-by: Benjamin Kaplan <[email protected]>
1 parent 1209495 commit 8d436da

File tree

8 files changed

+91
-50
lines changed

8 files changed

+91
-50
lines changed

mmv1/products/cloudrun/Service.yaml

+2-6
Original file line numberDiff line numberDiff line change
@@ -851,16 +851,14 @@ properties:
851851
name: csi
852852
description: |-
853853
A filesystem specified by the Container Storage Interface (CSI).
854-
min_version: beta
855854
properties:
856855
- !ruby/object:Api::Type::String
857856
name: 'driver'
858857
required: true
859858
description: |-
860859
Unique name representing the type of file system to be created. Cloud Run supports the following values:
861860
* gcsfuse.run.googleapis.com: Mount a Google Cloud Storage bucket using GCSFuse. This driver requires the
862-
run.googleapis.com/execution-environment annotation to be set to "gen2" and
863-
run.googleapis.com/launch-stage set to "BETA" or "ALPHA".
861+
run.googleapis.com/execution-environment annotation to be unset or set to "gen2"
864862
- !ruby/object:Api::Type::Boolean
865863
name: 'readOnly'
866864
default_from_api: true
@@ -876,9 +874,7 @@ properties:
876874
name: nfs
877875
description: |-
878876
A filesystem backed by a Network File System share. This filesystem requires the
879-
run.googleapis.com/execution-environment annotation to be set to "gen2" and
880-
run.googleapis.com/launch-stage set to "BETA" or "ALPHA".
881-
min_version: beta
877+
run.googleapis.com/execution-environment annotation to be unset or set to "gen2"
882878
properties:
883879
- !ruby/object:Api::Type::String
884880
name: server

mmv1/products/cloudrunv2/Job.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ properties:
535535
- !ruby/object:Api::Type::NestedObject
536536
name: 'gcs'
537537
description: |-
538-
Cloud Storage bucket mounted as a volume using GCSFuse. This feature requires the launch stage to be set to ALPHA or BETA.
539-
min_version: beta
538+
Cloud Storage bucket mounted as a volume using GCSFuse.
540539
# exactly_one_of:
541540
# - template.0.volumes.0.secret
542541
# - template.0.volumes.0.cloudSqlInstance
@@ -556,8 +555,7 @@ properties:
556555
- !ruby/object:Api::Type::NestedObject
557556
name: 'nfs'
558557
description: |-
559-
NFS share mounted as a volume. This feature requires the launch stage to be set to ALPHA or BETA.
560-
min_version: beta
558+
NFS share mounted as a volume.
561559
# exactly_one_of:
562560
# - template.0.volumes.0.secret
563561
# - template.0.volumes.0.cloudSqlInstance

mmv1/products/cloudrunv2/Service.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,10 @@ properties:
670670
HTTPGet specifies the http request to perform. Exactly one of HTTPGet or TCPSocket must be specified.
671671
send_empty_value: true
672672
allow_empty_object: true
673-
# exactly_one_of:
674-
# - template.0.containers.0.startupProbe.0.httpGet
675-
# - template.0.containers.0.startupProbe.0.tcpSocket
676-
# - template.0.containers.0.startupProbe.0.grpc
673+
# exactly_one_of:
674+
# - template.0.containers.0.startupProbe.0.httpGet
675+
# - template.0.containers.0.startupProbe.0.tcpSocket
676+
# - template.0.containers.0.startupProbe.0.grpc
677677
properties:
678678
- !ruby/object:Api::Type::String
679679
name: 'path'
@@ -709,10 +709,10 @@ properties:
709709
TCPSocket specifies an action involving a TCP port. Exactly one of HTTPGet or TCPSocket must be specified.
710710
send_empty_value: true
711711
allow_empty_object: true
712-
# exactly_one_of:
713-
# - template.0.containers.0.startupProbe.0.httpGet
714-
# - template.0.containers.0.startupProbe.0.tcpSocket
715-
# - template.0.containers.0.startupProbe.0.grpc
712+
# exactly_one_of:
713+
# - template.0.containers.0.startupProbe.0.httpGet
714+
# - template.0.containers.0.startupProbe.0.tcpSocket
715+
# - template.0.containers.0.startupProbe.0.grpc
716716
properties:
717717
- !ruby/object:Api::Type::Integer
718718
name: port
@@ -837,7 +837,7 @@ properties:
837837
- !ruby/object:Api::Type::NestedObject
838838
name: 'gcs'
839839
description: |-
840-
Cloud Storage bucket mounted as a volume using GCSFuse. This feature is only supported in the gen2 execution environment and requires launch-stage to be set to ALPHA or BETA.
840+
Cloud Storage bucket mounted as a volume using GCSFuse. This feature is only supported in the gen2 execution environment.
841841
# exactly_one_of:
842842
# - template.0.volumes.0.secret
843843
# - template.0.volumes.0.cloudSqlInstance

mmv1/templates/terraform/examples/cloudrunv2_service_mount_gcs.tf.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" {
33

44
location = "us-central1"
55
deletion_protection = false
6-
launch_stage = "BETA"
6+
77

88
template {
99
execution_environment = "EXECUTION_ENVIRONMENT_GEN2"

mmv1/templates/terraform/examples/cloudrunv2_service_mount_nfs.tf.erb

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ resource "google_cloud_run_v2_service" "<%= ctx[:primary_resource_id] %>" {
44
location = "us-central1"
55
deletion_protection = false
66
ingress = "INGRESS_TRAFFIC_ALL"
7-
launch_stage = "BETA"
87

98
template {
109
execution_environment = "EXECUTION_ENVIRONMENT_GEN2"

mmv1/third_party/terraform/services/cloudrun/resource_cloud_run_service_test.go.erb

+65-22
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,6 @@ resource "google_cloud_run_service" "default" {
13131313
`, context)
13141314
}
13151315

1316-
<% unless version == 'ga' -%>
13171316

13181317
func TestAccCloudRunService_csiVolume(t *testing.T) {
13191318
acctest.SkipIfVcr(t)
@@ -1324,10 +1323,10 @@ func TestAccCloudRunService_csiVolume(t *testing.T) {
13241323

13251324
acctest.VcrTest(t, resource.TestCase{
13261325
PreCheck: func() { acctest.AccTestPreCheck(t) },
1327-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
1326+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
13281327
Steps: []resource.TestStep{
13291328
{
1330-
Config: testAccCloudRunService_cloudRunServiceWithEmptyDirVolume(name, project),
1329+
Config: testAccCloudRunService_cloudRunServiceWithNoVolume(name, project),
13311330
},
13321331
{
13331332
ResourceName: "google_cloud_run_service.default",
@@ -1349,33 +1348,23 @@ func TestAccCloudRunService_csiVolume(t *testing.T) {
13491348
}
13501349

13511350

1352-
func testAccCloudRunService_cloudRunServiceWithEmptyDirVolume(name, project string) string {
1351+
func testAccCloudRunService_cloudRunServiceWithNoVolume(name, project string) string {
13531352
return fmt.Sprintf(`
13541353
resource "google_cloud_run_service" "default" {
1355-
provider = google-beta
13561354
name = "%s"
13571355
location = "us-central1"
13581356

13591357
metadata {
13601358
namespace = "%s"
13611359
annotations = {
13621360
generated-by = "magic-modules"
1363-
"run.googleapis.com/launch-stage" = "BETA"
13641361
}
13651362
}
13661363

13671364
template {
13681365
spec {
13691366
containers {
13701367
image = "gcr.io/cloudrun/hello"
1371-
volume_mounts {
1372-
name = "vol1"
1373-
mount_path = "/mnt/vol1"
1374-
}
1375-
}
1376-
volumes {
1377-
name = "vol1"
1378-
empty_dir { size_limit = "256Mi" }
13791368
}
13801369
}
13811370
}
@@ -1389,18 +1378,17 @@ resource "google_cloud_run_service" "default" {
13891378
`, name, project)
13901379
}
13911380

1381+
13921382
func testAccCloudRunService_cloudRunServiceUpdateWithGcsVolume(name, project string) string {
13931383
return fmt.Sprintf(`
13941384
resource "google_cloud_run_service" "default" {
1395-
provider = google-beta
13961385
name = "%s"
13971386
location = "us-central1"
13981387

13991388
metadata {
14001389
namespace = "%s"
14011390
annotations = {
14021391
generated-by = "magic-modules"
1403-
"run.googleapis.com/launch-stage" = "BETA"
14041392
}
14051393
}
14061394

@@ -1431,13 +1419,68 @@ resource "google_cloud_run_service" "default" {
14311419
}
14321420
}
14331421

1434-
lifecycle {
1435-
ignore_changes = [
1436-
metadata.0.annotations,
1437-
]
1438-
}
14391422
}
14401423
`, name, project)
14411424
}
14421425

1443-
<% end -%>
1426+
<% unless version == 'ga' -%>
1427+
1428+
func TestAccCloudRunService_emptyDirVolume(t *testing.T) {
1429+
t.Parallel()
1430+
1431+
project := envvar.GetTestProjectFromEnv()
1432+
name := "tftest-cloudrun-" + acctest.RandString(t, 6)
1433+
1434+
acctest.VcrTest(t, resource.TestCase{
1435+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1436+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
1437+
Steps: []resource.TestStep{
1438+
{
1439+
Config: testAccCloudRunService_cloudRunServiceWithEmptyDirVolume(name, project),
1440+
},
1441+
{
1442+
ResourceName: "google_cloud_run_service.default",
1443+
ImportState: true,
1444+
ImportStateVerify: true,
1445+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "metadata.0.annotations", "metadata.0.labels", "metadata.0.terraform_labels", "status.0.conditions"},
1446+
},
1447+
},
1448+
})
1449+
}
1450+
1451+
1452+
func testAccCloudRunService_cloudRunServiceWithEmptyDirVolume(name, project string) string {
1453+
return fmt.Sprintf(`
1454+
resource "google_cloud_run_service" "default" {
1455+
provider = google-beta
1456+
name = "%s"
1457+
location = "us-central1"
1458+
1459+
metadata {
1460+
namespace = "%s"
1461+
annotations = {
1462+
generated-by = "magic-modules"
1463+
"run.googleapis.com/launch-stage" = "BETA"
1464+
}
1465+
}
1466+
1467+
template {
1468+
spec {
1469+
containers {
1470+
image = "gcr.io/cloudrun/hello"
1471+
volume_mounts {
1472+
name = "vol1"
1473+
mount_path = "/mnt/vol1"
1474+
}
1475+
}
1476+
volumes {
1477+
name = "vol1"
1478+
empty_dir { size_limit = "256Mi" }
1479+
}
1480+
}
1481+
}
1482+
1483+
}
1484+
`, name, project)
1485+
}
1486+
<% end -%>

mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb

+11-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCAndNamedBinAuthPolicyUpdate(
309309
`, context)
310310
}
311311

312-
<% unless version == 'ga' -%>
313312
func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(t *testing.T) {
314313
acctest.SkipIfVcr(t)
315314
t.Parallel()
@@ -352,7 +351,6 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNoVolume(context map[string]interface
352351
name = "%{job_name}"
353352
location = "us-central1"
354353
deletion_protection = false
355-
launch_stage = "BETA"
356354
template {
357355
template {
358356
containers {
@@ -376,7 +374,6 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context map[string]interfac
376374
name = "%{job_name}"
377375
location = "us-central1"
378376
deletion_protection = false
379-
launch_stage = "BETA"
380377
template {
381378
template {
382379
containers {
@@ -395,6 +392,11 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context map[string]interfac
395392
}
396393
}
397394
}
395+
lifecycle {
396+
ignore_changes = [
397+
launch_stage,
398+
]
399+
}
398400
}
399401
`, context)
400402
}
@@ -441,7 +443,6 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(context map[string]interfac
441443
name = "%{job_name}"
442444
location = "us-central1"
443445
deletion_protection = false
444-
launch_stage = "BETA"
445446
template {
446447
template {
447448
containers {
@@ -461,10 +462,16 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(context map[string]interfac
461462
}
462463
}
463464
}
465+
lifecycle {
466+
ignore_changes = [
467+
launch_stage,
468+
]
469+
}
464470
}
465471
`, context)
466472
}
467473

474+
<% unless version == 'ga' -%>
468475
func TestAccCloudRunV2Job_cloudrunv2JobWithStartExecutionTokenUpdate(t *testing.T) {
469476
t.Parallel()
470477

mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb

+1-3
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ resource "google_compute_network" "custom_test" {
210210
}
211211
`, context)
212212
}
213-
<% unless version == 'ga' -%>
214213
func TestAccCloudRunV2Service_cloudrunv2ServiceGcsVolume(t *testing.T) {
215214
acctest.SkipIfVcr(t)
216215
t.Parallel()
@@ -244,7 +243,7 @@ resource "google_cloud_run_v2_service" "default" {
244243
description = "description creating"
245244
location = "us-central1"
246245
deletion_protection = false
247-
launch_stage = "BETA"
246+
248247
annotations = {
249248
generated-by = "magic-modules"
250249
}
@@ -313,7 +312,6 @@ resource "google_service_account" "service_account" {
313312
}
314313
`, context)
315314
}
316-
<%end -%>
317315
func TestAccCloudRunV2Service_cloudrunv2ServiceTCPProbesUpdate(t *testing.T) {
318316
t.Parallel()
319317

0 commit comments

Comments
 (0)