Skip to content

Commit 1b255b8

Browse files
authored
Merge branch 'kubernetes-sigs:main' into main
2 parents da844bc + b342343 commit 1b255b8

10 files changed

Lines changed: 258 additions & 238 deletions

File tree

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1818

19-
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
19+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
2020
with:
2121
go-version: "1.24"
2222
check-latest: true
2323
cache: false
2424

2525
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601 # v9.1.0
26+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
2727
with:
2828
version: v2.4

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ RELEASE_NOTES_VER := v0.11.0
8989
RELEASE_NOTES_BIN := release-notes
9090
RELEASE_NOTES := $(TOOLS_BIN_DIR)/$(RELEASE_NOTES_BIN)-$(RELEASE_NOTES_VER)
9191

92-
GINKGO_VER := v2.23.3
92+
GINKGO_VER := v2.27.5
9393
GINKGO_BIN := ginkgo
9494
GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)
9595
GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo

api/v1beta1/gcpcluster_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ type GCPClusterSpec struct {
6262

6363
// CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this cluster. If not
6464
// supplied then the credentials of the controller will be used.
65+
// When creating a new GCP client, the controller will try to extract the type
66+
// of credential from the JSON data, and it will request a client for the specific credential type.
6567
// +optional
6668
CredentialsRef *ObjectReference `json:"credentialsRef,omitempty"`
6769

cloud/scope/clients.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package scope
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"fmt"
2223
"time"
2324

@@ -43,6 +44,12 @@ type GCPServices struct {
4344
// GCPRateLimiter implements cloud.RateLimiter.
4445
type GCPRateLimiter struct{}
4546

47+
// credentialHeader is a helper struct used for determining the type of
48+
// GCP credentials from JSON data.
49+
type credentialHeader struct {
50+
Type string `json:"type"`
51+
}
52+
4653
// Accept blocks until the operation can be performed.
4754
func (rl *GCPRateLimiter) Accept(ctx context.Context, key *cloud.RateLimitKey) error {
4855
if key.Operation == "Get" && key.Service == "Operations" {
@@ -83,7 +90,22 @@ func defaultClientOptions(ctx context.Context, credentialsRef *infrav1.ObjectRef
8390
if err != nil {
8491
return nil, fmt.Errorf("getting gcp credentials from reference %s: %w", credentialsRef, err)
8592
}
86-
opts = append(opts, option.WithCredentialsJSON(rawData))
93+
94+
header := &credentialHeader{}
95+
if err := json.Unmarshal(rawData, header); err != nil {
96+
return nil, fmt.Errorf("parsing gcp credential type from reference %s: %w", credentialsRef, err)
97+
}
98+
99+
switch header.Type {
100+
case "service_account":
101+
opts = append(opts, option.WithAuthCredentialsJSON(option.ServiceAccount, rawData))
102+
case "external_account":
103+
opts = append(opts, option.WithAuthCredentialsJSON(option.ExternalAccount, rawData))
104+
case "impersonated_service_account":
105+
opts = append(opts, option.WithAuthCredentialsJSON(option.ImpersonatedServiceAccount, rawData))
106+
default:
107+
opts = append(opts, option.WithAuthCredentialsJSON(option.ServiceAccount, rawData))
108+
}
87109
}
88110

89111
return opts, nil

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ spec:
8686
description: |-
8787
CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this cluster. If not
8888
supplied then the credentials of the controller will be used.
89+
When creating a new GCP client, the controller will try to extract the type
90+
of credential from the JSON data, and it will request a client for the specific credential type.
8991
properties:
9092
name:
9193
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ spec:
103103
description: |-
104104
CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this cluster. If not
105105
supplied then the credentials of the controller will be used.
106+
When creating a new GCP client, the controller will try to extract the type
107+
of credential from the JSON data, and it will request a client for the specific credential type.
106108
properties:
107109
name:
108110
description: |-

controllers/gcpcluster_controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package controllers
1818

1919
import (
20+
"context"
21+
2022
. "github.com/onsi/ginkgo/v2"
2123
. "github.com/onsi/gomega"
22-
"golang.org/x/net/context"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2425
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
2526
ctrl "sigs.k8s.io/controller-runtime"

go.mod

Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,53 @@ go 1.24.0
55
toolchain go1.24.6
66

77
require (
8-
cloud.google.com/go/compute v1.48.0
9-
cloud.google.com/go/container v1.44.1
8+
cloud.google.com/go/compute v1.53.0
9+
cloud.google.com/go/container v1.45.0
1010
cloud.google.com/go/iam v1.5.3
1111
cloud.google.com/go/resourcemanager v1.10.7
1212
github.com/GoogleCloudPlatform/k8s-cloud-provider v1.34.0
1313
github.com/go-logr/logr v1.4.3
1414
github.com/google/go-cmp v0.7.0
15-
github.com/googleapis/gax-go/v2 v2.15.0
16-
github.com/onsi/ginkgo/v2 v2.26.0
17-
github.com/onsi/gomega v1.38.2
15+
github.com/googleapis/gax-go/v2 v2.16.0
16+
github.com/onsi/ginkgo/v2 v2.27.5
17+
github.com/onsi/gomega v1.39.0
1818
github.com/pkg/errors v0.9.1
1919
github.com/spf13/pflag v1.0.10
2020
github.com/stretchr/testify v1.11.1
21-
golang.org/x/crypto v0.43.0
22-
golang.org/x/mod v0.29.0
23-
golang.org/x/net v0.45.0
24-
google.golang.org/api v0.252.0
25-
google.golang.org/grpc v1.76.0
26-
k8s.io/api v0.33.3
27-
k8s.io/apimachinery v0.33.3
28-
k8s.io/client-go v0.33.3
29-
k8s.io/component-base v0.33.3
21+
golang.org/x/crypto v0.47.0
22+
golang.org/x/mod v0.32.0
23+
google.golang.org/api v0.260.0
24+
google.golang.org/grpc v1.78.0
25+
k8s.io/api v0.34.2
26+
k8s.io/apimachinery v0.34.2
27+
k8s.io/client-go v0.34.2
28+
k8s.io/component-base v0.34.2
3029
k8s.io/klog/v2 v2.130.1
31-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
32-
sigs.k8s.io/cluster-api v1.11.2
33-
sigs.k8s.io/cluster-api/test v1.11.0
34-
sigs.k8s.io/controller-runtime v0.21.0
30+
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
31+
sigs.k8s.io/cluster-api v1.11.4
32+
sigs.k8s.io/cluster-api/test v1.11.2
33+
sigs.k8s.io/controller-runtime v0.22.4
3534
)
3635

3736
require (
3837
github.com/containerd/errdefs v1.0.0 // indirect
3938
github.com/containerd/errdefs/pkg v0.3.0 // indirect
4039
github.com/moby/sys/sequential v0.6.0 // indirect
41-
go.uber.org/automaxprocs v1.6.0 // indirect
4240
go.yaml.in/yaml/v2 v2.4.2 // indirect
4341
go.yaml.in/yaml/v3 v3.0.4 // indirect
42+
golang.org/x/net v0.48.0 // indirect
4443
sigs.k8s.io/randfill v1.0.0 // indirect
44+
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
4545
)
4646

4747
require (
4848
al.essio.dev/pkg/shellescape v1.5.1 // indirect
4949
cel.dev/expr v0.24.0 // indirect
50-
cloud.google.com/go v0.121.6 // indirect
51-
cloud.google.com/go/auth v0.17.0 // indirect
50+
cloud.google.com/go v0.123.0 // indirect
51+
cloud.google.com/go/auth v0.18.0 // indirect
5252
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
5353
cloud.google.com/go/compute/metadata v0.9.0 // indirect
54-
cloud.google.com/go/longrunning v0.6.7 // indirect
54+
cloud.google.com/go/longrunning v0.7.0 // indirect
5555
github.com/BurntSushi/toml v1.4.0 // indirect
5656
github.com/MakeNowJust/heredoc v1.0.0 // indirect
5757
github.com/Masterminds/semver/v3 v3.4.0 // indirect
@@ -71,12 +71,12 @@ require (
7171
github.com/docker/go-connections v0.5.0 // indirect
7272
github.com/docker/go-units v0.4.0 // indirect
7373
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 // indirect
74-
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
74+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
7575
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
7676
github.com/fatih/color v1.18.0 // indirect
7777
github.com/felixge/httpsnoop v1.0.4 // indirect
78-
github.com/fsnotify/fsnotify v1.8.0 // indirect
79-
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
78+
github.com/fsnotify/fsnotify v1.9.0 // indirect
79+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
8080
github.com/go-logr/stdr v1.2.2 // indirect
8181
github.com/go-logr/zapr v1.3.0 // indirect
8282
github.com/go-openapi/jsonpointer v0.21.0 // indirect
@@ -87,82 +87,81 @@ require (
8787
github.com/gobuffalo/flect v1.0.3 // indirect
8888
github.com/gogo/protobuf v1.3.2 // indirect
8989
github.com/google/btree v1.1.3 // indirect
90-
github.com/google/cel-go v0.23.2 // indirect
91-
github.com/google/gnostic-models v0.6.9 // indirect
90+
github.com/google/cel-go v0.26.0 // indirect
91+
github.com/google/gnostic-models v0.7.0 // indirect
9292
github.com/google/go-github/v53 v53.2.0 // indirect
9393
github.com/google/go-querystring v1.1.0 // indirect
94-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
94+
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 // indirect
9595
github.com/google/s2a-go v0.1.9 // indirect
9696
github.com/google/uuid v1.6.0 // indirect
97-
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
98-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
97+
github.com/googleapis/enterprise-certificate-proxy v0.3.9 // indirect
98+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
9999
github.com/inconshreveable/mousetrap v1.1.0 // indirect
100100
github.com/josharian/intern v1.0.0 // indirect
101101
github.com/json-iterator/go v1.1.12 // indirect
102102
github.com/kylelemons/godebug v1.1.0 // indirect
103103
github.com/mailru/easyjson v0.7.7 // indirect
104-
github.com/mattn/go-colorable v0.1.13 // indirect
104+
github.com/mattn/go-colorable v0.1.14 // indirect
105105
github.com/mattn/go-isatty v0.0.20 // indirect
106-
github.com/mattn/go-runewidth v0.0.14 // indirect
106+
github.com/mattn/go-runewidth v0.0.16 // indirect
107107
github.com/moby/docker-image-spec v1.3.1 // indirect
108108
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
109-
github.com/modern-go/reflect2 v1.0.2 // indirect
109+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
110110
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
111111
github.com/olekukonko/tablewriter v0.0.5 // indirect
112112
github.com/opencontainers/go-digest v1.0.0 // indirect
113113
github.com/opencontainers/image-spec v1.0.2 // indirect
114114
github.com/pelletier/go-toml v1.9.5 // indirect
115-
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
115+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
116116
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
117117
github.com/prometheus/client_golang v1.22.0 // indirect
118-
github.com/prometheus/client_model v0.6.1 // indirect
118+
github.com/prometheus/client_model v0.6.2 // indirect
119119
github.com/prometheus/common v0.62.0 // indirect
120120
github.com/prometheus/procfs v0.15.1 // indirect
121-
github.com/rivo/uniseg v0.4.2 // indirect
122-
github.com/sagikazarmark/locafero v0.7.0 // indirect
123-
github.com/sourcegraph/conc v0.3.0 // indirect
124-
github.com/spf13/afero v1.12.0 // indirect
125-
github.com/spf13/cast v1.7.1 // indirect
126-
github.com/spf13/cobra v1.9.1 // indirect
127-
github.com/spf13/viper v1.20.1 // indirect
121+
github.com/rivo/uniseg v0.4.7 // indirect
122+
github.com/sagikazarmark/locafero v0.11.0 // indirect
123+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
124+
github.com/spf13/afero v1.15.0 // indirect
125+
github.com/spf13/cast v1.10.0 // indirect
126+
github.com/spf13/cobra v1.10.1 // indirect
127+
github.com/spf13/viper v1.21.0 // indirect
128128
github.com/stoewer/go-strcase v1.3.0 // indirect
129129
github.com/subosito/gotenv v1.6.0 // indirect
130130
github.com/x448/float16 v0.8.4 // indirect
131-
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
131+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
132132
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
133133
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
134-
go.opentelemetry.io/otel v1.37.0 // indirect
135-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
136-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect
137-
go.opentelemetry.io/otel/metric v1.37.0 // indirect
138-
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
139-
go.opentelemetry.io/otel/trace v1.37.0 // indirect
140-
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
134+
go.opentelemetry.io/otel v1.38.0 // indirect
135+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
136+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 // indirect
137+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
138+
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
139+
go.opentelemetry.io/otel/trace v1.38.0 // indirect
140+
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
141141
go.uber.org/multierr v1.11.0 // indirect
142-
go.uber.org/zap v1.27.0 // indirect; indirect// indirect
142+
go.uber.org/zap v1.27.1 // indirect; indirect// indirect
143143
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
144-
golang.org/x/oauth2 v0.31.0 // indirect
145-
golang.org/x/sync v0.17.0 // indirect
146-
golang.org/x/sys v0.37.0 // indirect
147-
golang.org/x/term v0.36.0 // indirect
148-
golang.org/x/text v0.30.0 // indirect
149-
golang.org/x/time v0.13.0 // indirect
150-
golang.org/x/tools v0.37.0 // indirect
144+
golang.org/x/oauth2 v0.34.0 // indirect
145+
golang.org/x/sync v0.19.0 // indirect
146+
golang.org/x/sys v0.40.0 // indirect
147+
golang.org/x/term v0.39.0 // indirect
148+
golang.org/x/text v0.33.0 // indirect
149+
golang.org/x/time v0.14.0 // indirect
150+
golang.org/x/tools v0.40.0 // indirect
151151
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
152-
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
153-
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
154-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251002232023-7c0ddcbb5797 // indirect
155-
google.golang.org/protobuf v1.36.10 // indirect
152+
google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 // indirect
153+
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
154+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
155+
google.golang.org/protobuf v1.36.11 // indirect
156156
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
157157
gopkg.in/inf.v0 v0.9.1 // indirect
158158
gopkg.in/yaml.v3 v3.0.1 // indirect
159-
k8s.io/apiextensions-apiserver v0.33.3 // indirect
160-
k8s.io/apiserver v0.33.3 // indirect
161-
k8s.io/cluster-bootstrap v0.33.3 // indirect
162-
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
159+
k8s.io/apiextensions-apiserver v0.34.2 // indirect
160+
k8s.io/apiserver v0.34.2 // indirect
161+
k8s.io/cluster-bootstrap v0.34.2 // indirect
162+
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
163163
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect
164-
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
165-
sigs.k8s.io/kind v0.29.0 // indirect
166-
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
164+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
165+
sigs.k8s.io/kind v0.30.0 // indirect
167166
sigs.k8s.io/yaml v1.6.0 // indirect
168167
)

0 commit comments

Comments
 (0)