Skip to content

Commit

Permalink
Merge branch 'main' into alarconesparza-chore-update-practices-345846215
Browse files Browse the repository at this point in the history
  • Loading branch information
telpirion authored Dec 12, 2024
2 parents 129a53a + e68a50c commit 1cbcbab
Show file tree
Hide file tree
Showing 112 changed files with 2,966 additions and 4,729 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# CNDB, Storage, and Infra-DB
/bigtable/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-native-db-dpes
/cloudsql/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/infra-db-sdk
/cloudsql/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-sql-connectors
/datastore/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-native-db-dpes
/firestore/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-native-db-dpes
/memorystore/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-native-db-dpes
Expand Down
4 changes: 2 additions & 2 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ assign_issues_by:
- labels:
- 'api: cloudsql'
to:
- GoogleCloudPlatform/infra-db-sdk
- GoogleCloudPlatform/cloud-sql-connectors
- labels:
- 'api: dlp'
to:
Expand Down Expand Up @@ -84,7 +84,7 @@ assign_prs_by:
- labels:
- 'api: cloudsql'
to:
- GoogleCloudPlatform/infra-db-sdk
- GoogleCloudPlatform/cloud-sql-connectors
- labels:
- 'api: dlp'
to:
Expand Down
4 changes: 2 additions & 2 deletions appengine/go11x/tasks/handle_task/handle_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -68,7 +68,7 @@ func taskHandler(w http.ResponseWriter, r *http.Request) {
queueName := r.Header.Get("X-Appengine-Queuename")

// Extract the request body for further task details.
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Printf("ReadAll: %v", err)
http.Error(w, "Internal Error", http.StatusInternalServerError)
Expand Down
8 changes: 4 additions & 4 deletions cloudsql/sqlserver/database-sql/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ require (
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.188.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect
Expand Down
16 changes: 8 additions & 8 deletions cloudsql/sqlserver/database-sql/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,8 @@ golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -1348,8 +1348,8 @@ golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -1432,8 +1432,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down Expand Up @@ -1466,8 +1466,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
4 changes: 4 additions & 0 deletions compute/disks/attach_regional_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package snippets

// [START compute_regional_disk_attach]
// [START compute_instance_attach_regional_disk_force]
import (
"context"
"fmt"
Expand All @@ -41,6 +42,8 @@ func attachRegionalDisk(w io.Writer, projectID, zone, instanceName, diskUrl stri
req := &computepb.AttachDiskInstanceRequest{
AttachedDiskResource: &computepb.AttachedDisk{
Source: &diskUrl,
// In case you want to force attach the disk
// ForceAttach: proto.Bool(true),
},
Instance: instanceName,
Project: projectID,
Expand All @@ -62,3 +65,4 @@ func attachRegionalDisk(w io.Writer, projectID, zone, instanceName, diskUrl stri
}

// [END compute_regional_disk_attach]
// [END compute_instance_attach_regional_disk_force]
65 changes: 65 additions & 0 deletions compute/disks/consistency_group_clone.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package snippets

// [START compute_consistency_group_add_disk]
import (
"context"
"fmt"
"io"

compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/protobuf/proto"
)

// cloneConsistencyGroup clones all disks in consistency group for a project in a given region.
func cloneConsistencyGroup(w io.Writer, projectID, region, groupName string) error {
// projectID := "your_project_id"
// region := "europe-west4"
// groupName := "your_group_name"

ctx := context.Background()
disksClient, err := compute.NewRegionDisksRESTClient(ctx)
if err != nil {
return fmt.Errorf("NewResourcePoliciesRESTClient: %w", err)
}
defer disksClient.Close()

consistencyGroupUrl := fmt.Sprintf("projects/%s/regions/%s/resourcePolicies/%s", projectID, region, groupName)

req := &computepb.BulkInsertRegionDiskRequest{
Project: projectID,
BulkInsertDiskResourceResource: &computepb.BulkInsertDiskResource{
SourceConsistencyGroupPolicy: proto.String(consistencyGroupUrl),
},
Region: region,
}

op, err := disksClient.BulkInsert(ctx, req)
if err != nil {
return fmt.Errorf("unable to add disk: %w", err)
}

if err = op.Wait(ctx); err != nil {
return fmt.Errorf("unable to wait for the operation: %w", err)
}

fmt.Fprintf(w, "Group cloned\n")

return nil
}

// [END compute_consistency_group_add_disk]
67 changes: 67 additions & 0 deletions compute/disks/consistency_group_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package snippets

// [START compute_consistency_group_list]
import (
"context"
"fmt"
"io"
"strings"

compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)

// listConsistencyGroup get list of disks in consistency group for a project in a given region.
func listConsistencyGroup(w io.Writer, projectID, region, groupName string) error {
// projectID := "your_project_id"
// region := "europe-west4"
// groupName := "your_group_name"

ctx := context.Background()
disksClient, err := compute.NewRegionDisksRESTClient(ctx)
if err != nil {
return fmt.Errorf("NewResourcePoliciesRESTClient: %w", err)
}
defer disksClient.Close()

req := &computepb.ListRegionDisksRequest{
Project: projectID,
Region: region,
}

it := disksClient.List(ctx, req)
for {
disk, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
return err
}

for _, diskPolicy := range disk.GetResourcePolicies() {
if strings.Contains(diskPolicy, groupName) {
fmt.Fprintf(w, "- %s\n", disk.GetName())
}
}
}

return nil
}

// [END compute_consistency_group_list]
65 changes: 65 additions & 0 deletions compute/disks/consistency_group_stop_replication.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package snippets

// [START compute_consistency_group_stop_replication]
import (
"context"
"fmt"
"io"

compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/protobuf/proto"
)

// stopReplicationConsistencyGroup stop replication for a consistency group for a project in a given region.
func stopReplicationConsistencyGroup(w io.Writer, projectID, region, groupName string) error {
// projectID := "your_project_id"
// region := "europe-west4"
// groupName := "your_group_name"

ctx := context.Background()
disksClient, err := compute.NewRegionDisksRESTClient(ctx)
if err != nil {
return fmt.Errorf("NewResourcePoliciesRESTClient: %w", err)
}
defer disksClient.Close()

consistencyGroupUrl := fmt.Sprintf("projects/%s/regions/%s/resourcePolicies/%s", projectID, region, groupName)

req := &computepb.StopGroupAsyncReplicationRegionDiskRequest{
Project: projectID,
DisksStopGroupAsyncReplicationResourceResource: &computepb.DisksStopGroupAsyncReplicationResource{
ResourcePolicy: proto.String(consistencyGroupUrl),
},
Region: region,
}

op, err := disksClient.StopGroupAsyncReplication(ctx, req)
if err != nil {
return fmt.Errorf("unable to stop replication: %w", err)
}

if err = op.Wait(ctx); err != nil {
return fmt.Errorf("unable to wait for the operation: %w", err)
}

fmt.Fprintf(w, "Group stopped replicating\n")

return nil
}

// [END compute_consistency_group_stop_replication]
Loading

0 comments on commit 1cbcbab

Please sign in to comment.