Skip to content

Commit 5df6273

Browse files
authored
Adds default_release field to UnitKind resource (#15224)
1 parent 0268d66 commit 5df6273

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

mmv1/products/saasservicemgmt/UnitKind.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Google Inc.
1+
# Copyright 2025 Google Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -31,6 +31,7 @@ examples:
3131
saas_name: example-saas
3232
cluster_unitkind_name: cluster-unitkind
3333
app_unitkind_name: app-unitkind
34+
release_name: example-release
3435
test_env_vars:
3536
project: 'PROJECT_NAME'
3637
bootstrap_iam:
@@ -64,6 +65,13 @@ properties:
6465
type: String
6566
description: The timestamp when the resource was created.
6667
output: true
68+
- name: defaultRelease
69+
type: String
70+
description: |-
71+
A reference to the Release object to use as default for creating new units
72+
of this UnitKind.
73+
If not specified, a new unit must explicitly reference which release to use
74+
for its creation.
6775
- name: dependencies
6876
type: Array
6977
description: |-
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
resource "google_saas_runtime_saas" "example_saas" {
22
provider = google-beta
33
saas_id = "{{index $.Vars "saas_name"}}"
4-
location = "global"
4+
location = "us-east1"
55

66
locations {
7-
name = "us-central1"
7+
name = "us-east1"
88
}
99
}
1010

1111
resource "google_saas_runtime_unit_kind" "cluster_unit_kind" {
1212
provider = google-beta
13-
location = "global"
13+
location = "us-east1"
1414
unit_kind_id = "{{index $.Vars "cluster_unitkind_name"}}"
1515
saas = google_saas_runtime_saas.example_saas.id
16+
default_release = "projects/{{index $.TestEnvVars "project"}}/locations/us-east1/releases/{{index $.Vars "release_name"}}"
1617
}
1718

1819
resource "google_saas_runtime_unit_kind" "{{$.PrimaryResourceId}}" {
1920
provider = google-beta
20-
location = "global"
21+
location = "us-east1"
2122
unit_kind_id = "{{index $.Vars "app_unitkind_name"}}"
2223
saas = google_saas_runtime_saas.example_saas.id
2324

@@ -26,3 +27,13 @@ resource "google_saas_runtime_unit_kind" "{{$.PrimaryResourceId}}" {
2627
alias = "cluster"
2728
}
2829
}
30+
31+
resource "google_saas_runtime_release" "example_release" {
32+
provider = google-beta
33+
location = "us-east1"
34+
release_id = "{{index $.Vars "release_name"}}"
35+
unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id
36+
blueprint {
37+
package = "us-central1-docker.pkg.dev/ci-test-project-188019/test-repo/tf-test-easysaas-alpha-image@sha256:7992fdbaeaf998ecd31a7f937bb26e38a781ecf49b24857a6176c1e9bfc299ee"
38+
}
39+
}

mmv1/third_party/terraform/services/saasruntime/resource_saas_runtime_unit_kind_test.go.tmpl

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/hashicorp/terraform-plugin-testing/plancheck"
1010

1111
"github.com/hashicorp/terraform-provider-google/google/acctest"
12+
"github.com/hashicorp/terraform-provider-google/google/envvar"
1213
)
1314

1415
func TestAccSaasRuntimeUnitKind_update(t *testing.T) {
@@ -21,6 +22,7 @@ func TestAccSaasRuntimeUnitKind_update(t *testing.T) {
2122
})
2223

2324
context := map[string]interface{}{
25+
"project": envvar.GetTestProjectFromEnv(),
2426
"random_suffix": acctest.RandString(t, 10),
2527
}
2628

@@ -60,23 +62,24 @@ func testAccSaasRuntimeUnitKind_basic(context map[string]interface{}) string {
6062
resource "google_saas_runtime_saas" "example_saas" {
6163
provider = google-beta
6264
saas_id = "tf-test-example-saas%{random_suffix}"
63-
location = "global"
65+
location = "us-east1"
6466

6567
locations {
66-
name = "us-central1"
68+
name = "us-east1"
6769
}
6870
}
6971

7072
resource "google_saas_runtime_unit_kind" "cluster_unit_kind" {
7173
provider = google-beta
72-
location = "global"
74+
location = "us-east1"
7375
unit_kind_id = "tf-test-cluster-unitkind%{random_suffix}"
7476
saas = google_saas_runtime_saas.example_saas.id
77+
default_release = "projects/%{project}/locations/us-east1/releases/tf-test-example-release%{random_suffix}"
7578
}
7679

7780
resource "google_saas_runtime_unit_kind" "example" {
7881
provider = google-beta
79-
location = "global"
82+
location = "us-east1"
8083
unit_kind_id = "tf-test-app-unitkind%{random_suffix}"
8184
saas = google_saas_runtime_saas.example_saas.id
8285

@@ -85,6 +88,16 @@ resource "google_saas_runtime_unit_kind" "example" {
8588
alias = "cluster"
8689
}
8790
}
91+
92+
resource "google_saas_runtime_release" "example_release" {
93+
provider = google-beta
94+
location = "us-east1"
95+
release_id = "tf-test-example-release%{random_suffix}"
96+
unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id
97+
blueprint {
98+
package = "us-central1-docker.pkg.dev/ci-test-project-188019/test-repo/tf-test-easysaas-alpha-image@sha256:7992fdbaeaf998ecd31a7f937bb26e38a781ecf49b24857a6176c1e9bfc299ee"
99+
}
100+
}
88101
`, context)
89102
}
90103

@@ -93,23 +106,24 @@ func testAccSaasRuntimeUnitKind_update(context map[string]interface{}) string {
93106
resource "google_saas_runtime_saas" "example_saas" {
94107
provider = google-beta
95108
saas_id = "tf-test-example-saas%{random_suffix}"
96-
location = "global"
109+
location = "us-east1"
97110

98111
locations {
99-
name = "us-central1"
112+
name = "us-east1"
100113
}
101114
}
102115

103116
resource "google_saas_runtime_unit_kind" "cluster_unit_kind" {
104117
provider = google-beta
105-
location = "global"
118+
location = "us-east1"
106119
unit_kind_id = "tf-test-cluster-unitkind%{random_suffix}"
107120
saas = google_saas_runtime_saas.example_saas.id
121+
default_release = "projects/%{project}/locations/us-east1/releases/tf-test-example-release%{random_suffix}"
108122
}
109123

110124
resource "google_saas_runtime_unit_kind" "example" {
111125
provider = google-beta
112-
location = "global"
126+
location = "us-east1"
113127
unit_kind_id = "tf-test-app-unitkind%{random_suffix}"
114128
saas = google_saas_runtime_saas.example_saas.id
115129

@@ -159,6 +173,16 @@ resource "google_saas_runtime_unit_kind" "example" {
159173
"annotation-one": "bar"
160174
}
161175
}
176+
177+
resource "google_saas_runtime_release" "example_release" {
178+
provider = google-beta
179+
location = "us-east1"
180+
release_id = "tf-test-example-release%{random_suffix}"
181+
unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id
182+
blueprint {
183+
package = "us-central1-docker.pkg.dev/ci-test-project-188019/test-repo/tf-test-easysaas-alpha-image@sha256:7992fdbaeaf998ecd31a7f937bb26e38a781ecf49b24857a6176c1e9bfc299ee"
184+
}
185+
}
162186
`, context)
163187
}
164188
{{- end }}

0 commit comments

Comments
 (0)