Skip to content

Commit e5e40cd

Browse files
committed
enable the BSL service account to be used for requests
1 parent d7c2024 commit e5e40cd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

velero-plugin-for-gcp/object_store.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,13 @@ func (o *ObjectStore) Init(config map[string]string) error {
158158
if err != nil {
159159
return errors.WithStack(err)
160160
}
161-
if o.fileCredType == serviceAccountKey {
161+
switch o.fileCredType {
162+
case serviceAccountKey:
162163
// Using Credentials File
163164
err = o.initFromKeyFile(creds)
165+
case externalAccountKey:
166+
// Using Workload Identity Federation - read serviceAccount from BSL config for signing
167+
err = o.initFromComputeEngine(config)
164168
}
165169
} else {
166170
// Using compute engine credentials. Use this if workload identity is enabled.

velero-plugin-for-gcp/object_store_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ func TestObjectExists(t *testing.T) {
158158
}
159159
}
160160

161+
func TestCreateSignedURL_emptyGoogleAccessID(t *testing.T) {
162+
o := newObjectStore(velerotest.NewLogger())
163+
// googleAccessID is empty — simulates external_account credentials with no serviceAccount in BSL config
164+
_, err := o.CreateSignedURL("bucket", "key", 0)
165+
require.EqualError(t, err, "GoogleAccessID is empty, perhaps using external_account credentials, cannot create signed URL")
166+
}
167+
161168
func Test_getSecretAccountKey(t *testing.T) {
162169
type args struct {
163170
secretByte []byte

0 commit comments

Comments
 (0)