Skip to content

Commit c80274d

Browse files
Merge pull request openshift#6896 from r4f4/gcp-monitoring-deprec
quota: gcp: replace deprecated monitoring package and fix linting issues
2 parents 3f2855a + 3d4b90b commit c80274d

File tree

167 files changed

+28374
-8732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+28374
-8732
lines changed

go.mod

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/openshift/installer
33
go 1.18
44

55
require (
6-
cloud.google.com/go/monitoring v1.6.0
6+
cloud.google.com/go/monitoring v1.12.0
77
github.com/AlecAivazis/survey/v2 v2.3.5
88
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible
99
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0
@@ -89,9 +89,9 @@ require (
8989
golang.org/x/oauth2 v0.4.0
9090
golang.org/x/sys v0.6.0
9191
golang.org/x/term v0.4.0
92-
google.golang.org/api v0.91.0
93-
google.golang.org/genproto v0.0.0-20220808131553-a91ffa7f803e
94-
google.golang.org/grpc v1.48.0
92+
google.golang.org/api v0.107.0
93+
google.golang.org/genproto v0.0.0-20230112194545-e10362b5ecf9
94+
google.golang.org/grpc v1.51.0
9595
gopkg.in/ini.v1 v1.66.6
9696
gopkg.in/yaml.v2 v2.4.0
9797
k8s.io/api v0.26.1
@@ -107,7 +107,8 @@ require (
107107
)
108108

109109
require (
110-
cloud.google.com/go/compute v1.7.0 // indirect
110+
cloud.google.com/go/compute v1.14.0 // indirect
111+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
111112
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1 // indirect
112113
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
113114
github.com/Azure/go-autorest/autorest/adal v0.9.21 // indirect
@@ -152,8 +153,8 @@ require (
152153
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
153154
github.com/google/gnostic v0.6.9 // indirect
154155
github.com/google/gofuzz v1.2.0 // indirect
155-
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
156-
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
156+
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
157+
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
157158
github.com/hashicorp/errwrap v1.0.0 // indirect
158159
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
159160
github.com/hashicorp/go-hclog v1.2.0 // indirect
@@ -204,7 +205,7 @@ require (
204205
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
205206
github.com/zclconf/go-cty v1.11.0 // indirect
206207
go.mongodb.org/mongo-driver v1.8.3 // indirect
207-
go.opencensus.io v0.23.0 // indirect
208+
go.opencensus.io v0.24.0 // indirect
208209
go.opentelemetry.io/otel v1.11.1 // indirect
209210
go.opentelemetry.io/otel/trace v1.11.1 // indirect
210211
go.uber.org/atomic v1.7.0 // indirect

go.sum

Lines changed: 20 additions & 100 deletions
Large diffs are not rendered by default.

pkg/quota/gcp/gcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"sort"
77
"strings"
88

9-
monitoring "cloud.google.com/go/monitoring/apiv3"
9+
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
1010
"github.com/pkg/errors"
1111
"google.golang.org/api/googleapi"
1212
"google.golang.org/api/option"
@@ -91,7 +91,7 @@ func newQuotas(usages []record, limits []record) []quota.Quota {
9191
return record{}, false
9292
}
9393

94-
var quotas []quota.Quota
94+
quotas := make([]quota.Quota, 0, len(limits))
9595
for _, l := range limits {
9696
q := quota.Quota{
9797
Service: l.Service,

pkg/quota/gcp/usage.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"fmt"
66
"time"
77

8-
monitoring "cloud.google.com/go/monitoring/apiv3"
8+
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
9+
"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
910
googlepb "github.com/golang/protobuf/ptypes/timestamp"
1011
"github.com/pkg/errors"
1112
"google.golang.org/api/iterator"
1213
"google.golang.org/genproto/googleapis/api/metric"
13-
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
1414
)
1515

1616
// loadUsage loads the usage from `consumer_quota` metric type for the project. It pulls metric data for last hour and
@@ -33,7 +33,7 @@ func loadUsage(ctx context.Context, client *monitoring.MetricClient, project str
3333
it := client.ListTimeSeries(ctx, req)
3434
for {
3535
resp, err := it.Next()
36-
if err == iterator.Done {
36+
if errors.Is(err, iterator.Done) {
3737
break
3838
}
3939
if err != nil {
@@ -48,7 +48,7 @@ func loadUsage(ctx context.Context, client *monitoring.MetricClient, project str
4848
return usages, nil
4949
}
5050

51-
// latestRecord find the latest data point for the timeseries ans retuns that as the usage for the metric type.
51+
// latestRecord find the latest data point for the timeseries and returns that as the usage for the metric type.
5252
// Based on https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries and definition of the points API
5353
// "The data points of this time series. When listing time series, points are returned in reverse time order.",
5454
// The latestRecord returns the first element of the points as the usage value. In case the points list is empty it

vendor/cloud.google.com/go/compute/internal/version.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/cloud.google.com/go/compute/metadata/CHANGES.md

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/cloud.google.com/go/compute/metadata/LICENSE

Lines changed: 202 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/cloud.google.com/go/compute/metadata/README.md

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/cloud.google.com/go/compute/metadata/metadata.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)