Skip to content

Commit a84dd8b

Browse files
committed
add support for universe domain for backup and volume snapshot
1 parent 5e94ed2 commit a84dd8b

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

velero-plugin-for-gcp/object_store.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ func (o *ObjectStore) initFromComputeEngine(config map[string]string) error {
211211
if !ok {
212212
return errors.Errorf("serviceAccount is expected to be provided as an item in BackupStorageLocation's config")
213213
}
214-
o.iamSvc, err = iamcredentials.NewService(context.Background())
214+
clientOptions := []option.ClientOption{}
215+
// if using a universeDomain, we need to pass it when initiate a new iam credentials service
216+
if universeDomain, ok := config[universeDomainKey]; ok {
217+
clientOptions = append(clientOptions, option.WithUniverseDomain(universeDomain))
218+
}
219+
o.iamSvc, err = iamcredentials.NewService(context.Background(), clientOptions...)
215220
return err
216221
}
217222

velero-plugin-for-gcp/volume_snapshotter.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ import (
4040
)
4141

4242
const (
43-
zoneSeparator = "__"
44-
projectKey = "project"
45-
snapshotLocationKey = "snapshotLocation"
46-
snapshotTypeKey = "snapshotType"
47-
volumeProjectKey = "volumeProject"
43+
zoneSeparator = "__"
44+
projectKey = "project"
45+
snapshotLocationKey = "snapshotLocation"
46+
snapshotTypeKey = "snapshotType"
47+
volumeProjectKey = "volumeProject"
48+
snapshotUniverseDomainKey = "universeDomain"
4849
)
4950

5051
var pdCSIDriver = map[string]bool{
@@ -75,6 +76,7 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error {
7576
projectKey,
7677
credentialsFileConfigKey,
7778
volumeProjectKey,
79+
snapshotUniverseDomainKey,
7880
); err != nil {
7981
return err
8082
}
@@ -136,6 +138,11 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error {
136138
return errors.Errorf("unsupported snapshot type: %q", snapshotType)
137139
}
138140

141+
// if universeDomain is provided, we need to pass it when creating new compute service client.
142+
if snapshotUniverseDomain, ok := config[snapshotUniverseDomainKey]; ok {
143+
clientOptions = append(clientOptions, option.WithUniverseDomain(snapshotUniverseDomain))
144+
}
145+
139146
gce, err := compute.NewService(context.TODO(), clientOptions...)
140147
if err != nil {
141148
return errors.WithStack(err)

velero-plugin-for-gcp/volume_snapshotter_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,13 @@ func TestInit(t *testing.T) {
470470
},
471471
},
472472
{
473-
name: "Init with archive snapshot type.",
473+
name: "Init with archive snapshot type and custom universe domain.",
474474
config: map[string]string{
475475
"project": "project-a",
476476
"snapshotLocation": "default",
477477
"snapshotType": "archive",
478478
"volumeProject": "project-b",
479+
"universeDomain": "googleapis-ppd.com",
479480
},
480481
expectedVolumeSnapshotter: VolumeSnapshotter{
481482
snapshotLocation: "default",

volumesnapshotlocation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ spec:
4646
#
4747
# Optional (default to STANDARD).
4848
snapshotType: snapshot-type
49+
50+
# Configuration of the universe domain.
51+
#
52+
# Optional.
53+
universeDomain: googleapis.com
4954
```

0 commit comments

Comments
 (0)