Skip to content

Commit 6b55257

Browse files
5.0.0 - Upgrade DCL to 1.52 (#9055) (#15989)
Signed-off-by: Modular Magician <[email protected]>
1 parent f58b94c commit 6b55257

10 files changed

+160
-126
lines changed

.changelog/9055.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```release-note:breaking-change
2+
firebase: made `google_firebase_rules.release` immutable
3+
```
4+
```release-note:enhancement
5+
containeraws: added `binary_authorization` to `google_container_aws_cluster`
6+
```
7+
```release-note:enhancement
8+
containeraws: added `update_settings` to `google_container_aws_node_pool`
9+
```

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ go 1.19
33

44
require (
55
cloud.google.com/go/bigtable v1.19.0
6-
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0
6+
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.52.0
77
github.com/apparentlymart/go-cidr v1.1.0
88
github.com/davecgh/go-spew v1.1.1
99
github.com/dnaeon/go-vcr v1.0.1

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ cloud.google.com/go/longrunning v0.5.1/go.mod h1:spvimkwdz6SPWKEt/XBij79E9fiTkHS
1717
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
1818
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0 h1:YhWTPhOf6gVpA9mSfnLOuL8Y6j8W5pzmHE7flXjTke4=
1919
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k=
20+
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.52.0 h1:KswxXF4E5iWv2ggktqv265zOvwmXA3mgma3UQfYA4tU=
21+
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.52.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k=
2022
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
2123
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
2224
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
@@ -428,5 +430,3 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
428430
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
429431
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
430432
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
431-
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0 h1:YhWTPhOf6gVpA9mSfnLOuL8Y6j8W5pzmHE7flXjTke4=
432-
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k=

google/services/containeraws/resource_container_aws_cluster.go

+95-40
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ func ResourceContainerAwsCluster() *schema.Resource {
111111
Elem: ContainerAwsClusterNetworkingSchema(),
112112
},
113113

114+
"binary_authorization": {
115+
Type: schema.TypeList,
116+
Computed: true,
117+
Optional: true,
118+
Description: "Configuration options for the Binary Authorization feature.",
119+
MaxItems: 1,
120+
Elem: ContainerAwsClusterBinaryAuthorizationSchema(),
121+
},
122+
114123
"description": {
115124
Type: schema.TypeString,
116125
Optional: true,
@@ -540,6 +549,19 @@ func ContainerAwsClusterNetworkingSchema() *schema.Resource {
540549
}
541550
}
542551

552+
func ContainerAwsClusterBinaryAuthorizationSchema() *schema.Resource {
553+
return &schema.Resource{
554+
Schema: map[string]*schema.Schema{
555+
"evaluation_mode": {
556+
Type: schema.TypeString,
557+
Computed: true,
558+
Optional: true,
559+
Description: "Mode of operation for Binary Authorization policy evaluation. Possible values: DISABLED, PROJECT_SINGLETON_POLICY_ENFORCE",
560+
},
561+
},
562+
}
563+
}
564+
543565
func ContainerAwsClusterWorkloadIdentityConfigSchema() *schema.Resource {
544566
return &schema.Resource{
545567
Schema: map[string]*schema.Schema{
@@ -572,16 +594,17 @@ func resourceContainerAwsClusterCreate(d *schema.ResourceData, meta interface{})
572594
}
573595

574596
obj := &containeraws.Cluster{
575-
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
576-
AwsRegion: dcl.String(d.Get("aws_region").(string)),
577-
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
578-
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
579-
Location: dcl.String(d.Get("location").(string)),
580-
Name: dcl.String(d.Get("name").(string)),
581-
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
582-
Description: dcl.String(d.Get("description").(string)),
583-
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
584-
Project: dcl.String(project),
597+
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
598+
AwsRegion: dcl.String(d.Get("aws_region").(string)),
599+
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
600+
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
601+
Location: dcl.String(d.Get("location").(string)),
602+
Name: dcl.String(d.Get("name").(string)),
603+
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
604+
BinaryAuthorization: expandContainerAwsClusterBinaryAuthorization(d.Get("binary_authorization")),
605+
Description: dcl.String(d.Get("description").(string)),
606+
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
607+
Project: dcl.String(project),
585608
}
586609

587610
id, err := obj.ID()
@@ -629,16 +652,17 @@ func resourceContainerAwsClusterRead(d *schema.ResourceData, meta interface{}) e
629652
}
630653

631654
obj := &containeraws.Cluster{
632-
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
633-
AwsRegion: dcl.String(d.Get("aws_region").(string)),
634-
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
635-
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
636-
Location: dcl.String(d.Get("location").(string)),
637-
Name: dcl.String(d.Get("name").(string)),
638-
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
639-
Description: dcl.String(d.Get("description").(string)),
640-
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
641-
Project: dcl.String(project),
655+
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
656+
AwsRegion: dcl.String(d.Get("aws_region").(string)),
657+
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
658+
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
659+
Location: dcl.String(d.Get("location").(string)),
660+
Name: dcl.String(d.Get("name").(string)),
661+
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
662+
BinaryAuthorization: expandContainerAwsClusterBinaryAuthorization(d.Get("binary_authorization")),
663+
Description: dcl.String(d.Get("description").(string)),
664+
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
665+
Project: dcl.String(project),
642666
}
643667

644668
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
@@ -684,6 +708,9 @@ func resourceContainerAwsClusterRead(d *schema.ResourceData, meta interface{}) e
684708
if err = d.Set("networking", flattenContainerAwsClusterNetworking(res.Networking)); err != nil {
685709
return fmt.Errorf("error setting networking in state: %s", err)
686710
}
711+
if err = d.Set("binary_authorization", flattenContainerAwsClusterBinaryAuthorization(res.BinaryAuthorization)); err != nil {
712+
return fmt.Errorf("error setting binary_authorization in state: %s", err)
713+
}
687714
if err = d.Set("description", res.Description); err != nil {
688715
return fmt.Errorf("error setting description in state: %s", err)
689716
}
@@ -731,16 +758,17 @@ func resourceContainerAwsClusterUpdate(d *schema.ResourceData, meta interface{})
731758
}
732759

733760
obj := &containeraws.Cluster{
734-
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
735-
AwsRegion: dcl.String(d.Get("aws_region").(string)),
736-
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
737-
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
738-
Location: dcl.String(d.Get("location").(string)),
739-
Name: dcl.String(d.Get("name").(string)),
740-
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
741-
Description: dcl.String(d.Get("description").(string)),
742-
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
743-
Project: dcl.String(project),
761+
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
762+
AwsRegion: dcl.String(d.Get("aws_region").(string)),
763+
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
764+
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
765+
Location: dcl.String(d.Get("location").(string)),
766+
Name: dcl.String(d.Get("name").(string)),
767+
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
768+
BinaryAuthorization: expandContainerAwsClusterBinaryAuthorization(d.Get("binary_authorization")),
769+
Description: dcl.String(d.Get("description").(string)),
770+
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
771+
Project: dcl.String(project),
744772
}
745773
directive := tpgdclresource.UpdateDirective
746774
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
@@ -783,16 +811,17 @@ func resourceContainerAwsClusterDelete(d *schema.ResourceData, meta interface{})
783811
}
784812

785813
obj := &containeraws.Cluster{
786-
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
787-
AwsRegion: dcl.String(d.Get("aws_region").(string)),
788-
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
789-
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
790-
Location: dcl.String(d.Get("location").(string)),
791-
Name: dcl.String(d.Get("name").(string)),
792-
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
793-
Description: dcl.String(d.Get("description").(string)),
794-
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
795-
Project: dcl.String(project),
814+
Authorization: expandContainerAwsClusterAuthorization(d.Get("authorization")),
815+
AwsRegion: dcl.String(d.Get("aws_region").(string)),
816+
ControlPlane: expandContainerAwsClusterControlPlane(d.Get("control_plane")),
817+
Fleet: expandContainerAwsClusterFleet(d.Get("fleet")),
818+
Location: dcl.String(d.Get("location").(string)),
819+
Name: dcl.String(d.Get("name").(string)),
820+
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
821+
BinaryAuthorization: expandContainerAwsClusterBinaryAuthorization(d.Get("binary_authorization")),
822+
Description: dcl.String(d.Get("description").(string)),
823+
Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")),
824+
Project: dcl.String(project),
796825
}
797826

798827
log.Printf("[DEBUG] Deleting Cluster %q", d.Id())
@@ -1233,6 +1262,32 @@ func flattenContainerAwsClusterNetworking(obj *containeraws.ClusterNetworking) i
12331262

12341263
}
12351264

1265+
func expandContainerAwsClusterBinaryAuthorization(o interface{}) *containeraws.ClusterBinaryAuthorization {
1266+
if o == nil {
1267+
return nil
1268+
}
1269+
objArr := o.([]interface{})
1270+
if len(objArr) == 0 || objArr[0] == nil {
1271+
return nil
1272+
}
1273+
obj := objArr[0].(map[string]interface{})
1274+
return &containeraws.ClusterBinaryAuthorization{
1275+
EvaluationMode: containeraws.ClusterBinaryAuthorizationEvaluationModeEnumRef(obj["evaluation_mode"].(string)),
1276+
}
1277+
}
1278+
1279+
func flattenContainerAwsClusterBinaryAuthorization(obj *containeraws.ClusterBinaryAuthorization) interface{} {
1280+
if obj == nil || obj.Empty() {
1281+
return nil
1282+
}
1283+
transformed := map[string]interface{}{
1284+
"evaluation_mode": obj.EvaluationMode,
1285+
}
1286+
1287+
return []interface{}{transformed}
1288+
1289+
}
1290+
12361291
func flattenContainerAwsClusterWorkloadIdentityConfig(obj *containeraws.ClusterWorkloadIdentityConfig) interface{} {
12371292
if obj == nil || obj.Empty() {
12381293
return nil

google/services/firebaserules/resource_firebaserules_release.go

+1-46
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func ResourceFirebaserulesRelease() *schema.Resource {
3939
return &schema.Resource{
4040
Create: resourceFirebaserulesReleaseCreate,
4141
Read: resourceFirebaserulesReleaseRead,
42-
Update: resourceFirebaserulesReleaseUpdate,
4342
Delete: resourceFirebaserulesReleaseDelete,
4443

4544
Importer: &schema.ResourceImporter{
@@ -48,7 +47,6 @@ func ResourceFirebaserulesRelease() *schema.Resource {
4847

4948
Timeouts: &schema.ResourceTimeout{
5049
Create: schema.DefaultTimeout(20 * time.Minute),
51-
Update: schema.DefaultTimeout(20 * time.Minute),
5250
Delete: schema.DefaultTimeout(20 * time.Minute),
5351
},
5452
CustomizeDiff: customdiff.All(
@@ -66,6 +64,7 @@ func ResourceFirebaserulesRelease() *schema.Resource {
6664
"ruleset_name": {
6765
Type: schema.TypeString,
6866
Required: true,
67+
ForceNew: true,
6968
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
7069
Description: "Name of the `Ruleset` referred to by this `Release`. The `Ruleset` must exist for the `Release` to be created.",
7170
},
@@ -206,50 +205,6 @@ func resourceFirebaserulesReleaseRead(d *schema.ResourceData, meta interface{})
206205

207206
return nil
208207
}
209-
func resourceFirebaserulesReleaseUpdate(d *schema.ResourceData, meta interface{}) error {
210-
config := meta.(*transport_tpg.Config)
211-
project, err := tpgresource.GetProject(d, config)
212-
if err != nil {
213-
return err
214-
}
215-
216-
obj := &firebaserules.Release{
217-
Name: dcl.String(d.Get("name").(string)),
218-
RulesetName: dcl.String(d.Get("ruleset_name").(string)),
219-
Project: dcl.String(project),
220-
}
221-
directive := tpgdclresource.UpdateDirective
222-
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
223-
if err != nil {
224-
return err
225-
}
226-
227-
billingProject := ""
228-
// err == nil indicates that the billing_project value was found
229-
if bp, err := tpgresource.GetBillingProject(d, config); err == nil {
230-
billingProject = bp
231-
}
232-
client := transport_tpg.NewDCLFirebaserulesClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutUpdate))
233-
if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil {
234-
d.SetId("")
235-
return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err)
236-
} else {
237-
client.Config.BasePath = bp
238-
}
239-
res, err := client.ApplyRelease(context.Background(), obj, directive...)
240-
241-
if _, ok := err.(dcl.DiffAfterApplyError); ok {
242-
log.Printf("[DEBUG] Diff after apply returned from the DCL: %s", err)
243-
} else if err != nil {
244-
// The resource didn't actually create
245-
d.SetId("")
246-
return fmt.Errorf("Error updating Release: %s", err)
247-
}
248-
249-
log.Printf("[DEBUG] Finished creating Release %q: %#v", d.Id(), res)
250-
251-
return resourceFirebaserulesReleaseRead(d, meta)
252-
}
253208

254209
func resourceFirebaserulesReleaseDelete(d *schema.ResourceData, meta interface{}) error {
255210
config := meta.(*transport_tpg.Config)

google/services/firebaserules/resource_firebaserules_release_generated_test.go

-36
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ func TestAccFirebaserulesRelease_FirestoreReleaseHandWritten(t *testing.T) {
5454
ImportState: true,
5555
ImportStateVerify: true,
5656
},
57-
{
58-
Config: testAccFirebaserulesRelease_FirestoreReleaseHandWrittenUpdate0(context),
59-
},
60-
{
61-
ResourceName: "google_firebaserules_release.primary",
62-
ImportState: true,
63-
ImportStateVerify: true,
64-
},
6557
},
6658
})
6759
}
@@ -94,34 +86,6 @@ resource "google_firebaserules_ruleset" "firestore" {
9486
`, context)
9587
}
9688

97-
func testAccFirebaserulesRelease_FirestoreReleaseHandWrittenUpdate0(context map[string]interface{}) string {
98-
return acctest.Nprintf(`
99-
resource "google_firebaserules_release" "primary" {
100-
name = "cloud.firestore"
101-
ruleset_name = "projects/%{project_name}/rulesets/${google_firebaserules_ruleset.firestore.name}"
102-
project = "%{project_name}"
103-
104-
lifecycle {
105-
replace_triggered_by = [
106-
google_firebaserules_ruleset.firestore
107-
]
108-
}
109-
}
110-
111-
resource "google_firebaserules_ruleset" "firestore" {
112-
source {
113-
files {
114-
content = "service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if request.auth != null; } } }"
115-
name = "firestore.rules"
116-
}
117-
}
118-
119-
project = "%{project_name}"
120-
}
121-
122-
`, context)
123-
}
124-
12589
func testAccCheckFirebaserulesReleaseDestroyProducer(t *testing.T) func(s *terraform.State) error {
12690
return func(s *terraform.State) error {
12791
for name, rs := range s.RootModule().Resources {

google/tpgdclresource/tpgtools_utils.go

+22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package tpgdclresource
44

55
import (
6+
"context"
67
"fmt"
78
"log"
89

@@ -26,3 +27,24 @@ func HandleNotFoundDCLError(err error, d *schema.ResourceData, resourceName stri
2627
return errwrap.Wrapf(
2728
fmt.Sprintf("Error when reading or editing %s: {{err}}", resourceName), err)
2829
}
30+
31+
func ResourceContainerAwsNodePoolCustomizeDiffFunc(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error {
32+
count := diff.Get("update_settings.#").(int)
33+
if count < 1 {
34+
return nil
35+
}
36+
37+
oMaxSurge, nMaxSurge := diff.GetChange("update_settings.0.surge_settings.0.max_surge")
38+
oMaxUnavailable, nMaxUnavailable := diff.GetChange("update_settings.0.surge_settings.0.max_unavailable")
39+
40+
// Server default of maxSurge = 1 and maxUnavailable = 0 is not returned
41+
// Clear the diff if trying to resolve these specific values
42+
if oMaxSurge == 0 && nMaxSurge == 1 && oMaxUnavailable == 0 && nMaxUnavailable == 0 {
43+
err := diff.Clear("update_settings")
44+
if err != nil {
45+
return err
46+
}
47+
}
48+
49+
return nil
50+
}

0 commit comments

Comments
 (0)