dependencies: migrate go-genproto to google-cloud-go

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2022-12-08 11:26:51 +01:00
parent eff3dd8aea
commit 9b1551e76a
28 changed files with 49 additions and 48 deletions

View file

@ -10,8 +10,8 @@ import (
"context"
compute "cloud.google.com/go/compute/apiv1"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/googleapis/gax-go/v2"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
)
type projectAPI interface {

View file

@ -10,9 +10,9 @@ import (
"context"
compute "cloud.google.com/go/compute/apiv1"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"google.golang.org/protobuf/proto"
)

View file

@ -10,7 +10,7 @@ import (
"fmt"
"regexp"
"google.golang.org/genproto/googleapis/cloud/compute/v1"
"cloud.google.com/go/compute/apiv1/computepb"
)
var (
@ -19,12 +19,12 @@ var (
)
// diskSourceToDiskReq converts a disk source URI to a disk request.
func diskSourceToDiskReq(diskSource string) (*compute.GetDiskRequest, error) {
func diskSourceToDiskReq(diskSource string) (*computepb.GetDiskRequest, error) {
matches := diskSourceRegex.FindStringSubmatch(diskSource)
if len(matches) != 4 {
return nil, fmt.Errorf("error splitting diskSource: %v", diskSource)
}
return &compute.GetDiskRequest{
return &computepb.GetDiskRequest{
Disk: matches[3],
Project: matches[1],
Zone: matches[2],

View file

@ -9,20 +9,20 @@ package client
import (
"testing"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/genproto/googleapis/cloud/compute/v1"
)
func TestDiskSourceToDiskReq(t *testing.T) {
testCases := map[string]struct {
diskSource string
wantRequest *compute.GetDiskRequest
wantRequest *computepb.GetDiskRequest
wantErr bool
}{
"valid request": {
diskSource: "https://www.googleapis.com/compute/v1/projects/project/zones/zone/disks/disk",
wantRequest: &compute.GetDiskRequest{
wantRequest: &computepb.GetDiskRequest{
Disk: "disk",
Project: "project",
Zone: "zone",

View file

@ -10,8 +10,8 @@ import (
"context"
compute "cloud.google.com/go/compute/apiv1"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/googleapis/gax-go/v2"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
)
type instanceTemplateClient struct {

View file

@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
package client
import (
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"cloud.google.com/go/compute/apiv1/computepb"
)
// getMetadataByKey returns the value of the metadata key in the given metadata.

View file

@ -9,20 +9,20 @@ package client
import (
"testing"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/stretchr/testify/assert"
"google.golang.org/genproto/googleapis/cloud/compute/v1"
"google.golang.org/protobuf/proto"
)
func TestGetMetadataByKey(t *testing.T) {
testCases := map[string]struct {
metadata *compute.Metadata
metadata *computepb.Metadata
key string
wantValue string
}{
"metadata has key": {
metadata: &compute.Metadata{
Items: []*compute.Items{
metadata: &computepb.Metadata{
Items: []*computepb.Items{
{Key: proto.String("key"), Value: proto.String("value")},
},
},
@ -30,8 +30,8 @@ func TestGetMetadataByKey(t *testing.T) {
wantValue: "value",
},
"metadata does not have key": {
metadata: &compute.Metadata{
Items: []*compute.Items{
metadata: &computepb.Metadata{
Items: []*computepb.Items{
{Key: proto.String("otherkey"), Value: proto.String("value")},
},
},
@ -39,8 +39,8 @@ func TestGetMetadataByKey(t *testing.T) {
wantValue: "",
},
"metadata contains invalid item": {
metadata: &compute.Metadata{
Items: []*compute.Items{
metadata: &computepb.Metadata{
Items: []*computepb.Items{
{},
{Key: proto.String("key"), Value: proto.String("value")},
},

View file

@ -10,7 +10,7 @@ import (
"context"
"fmt"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/protobuf/proto"
)

View file

@ -13,9 +13,9 @@ import (
"testing"
"time"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"google.golang.org/protobuf/proto"
)

View file

@ -11,10 +11,10 @@ import (
"errors"
"net/http"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/edgelesssys/constellation/operators/constellation-node-operator/v2/api/v1alpha1"
updatev1alpha1 "github.com/edgelesssys/constellation/operators/constellation-node-operator/v2/api/v1alpha1"
"google.golang.org/api/googleapi"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
)
// GetNodeState returns the state of the node.

View file

@ -12,11 +12,11 @@ import (
"net/http"
"testing"
"cloud.google.com/go/compute/apiv1/computepb"
updatev1alpha1 "github.com/edgelesssys/constellation/operators/constellation-node-operator/v2/api/v1alpha1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/api/googleapi"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"google.golang.org/protobuf/proto"
)

View file

@ -11,7 +11,7 @@ import (
"errors"
"regexp"
"google.golang.org/genproto/googleapis/cloud/compute/v1"
"cloud.google.com/go/compute/apiv1/computepb"
)
var numericProjectIDRegex = regexp.MustCompile(`^\d+$`)
@ -21,7 +21,7 @@ func (c *Client) canonicalProjectID(ctx context.Context, project string) (string
if !numericProjectIDRegex.MatchString(project) {
return project, nil
}
computeProject, err := c.projectAPI.Get(ctx, &compute.GetProjectRequest{Project: project})
computeProject, err := c.projectAPI.Get(ctx, &computepb.GetProjectRequest{Project: project})
if err != nil {
return "", err
}

View file

@ -11,9 +11,9 @@ import (
"errors"
"testing"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"google.golang.org/protobuf/proto"
)

View file

@ -12,8 +12,8 @@ import (
"fmt"
"strings"
"cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
)
// GetScalingGroupImage returns the image URI of the scaling group.

View file

@ -11,9 +11,9 @@ import (
"errors"
"testing"
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
"google.golang.org/protobuf/proto"
)