Skip to content

Commit

Permalink
add endpoint for GCP objectstore client
Browse files Browse the repository at this point in the history
add endpoint for GCP objectstore client

Signed-off-by: William Li <[email protected]>

sign off

Signed-off-by: William Li <[email protected]>

format code

Signed-off-by: William Li <[email protected]>

remove wrong files

Signed-off-by: William Li <[email protected]>

update go module

Signed-off-by: William Li <[email protected]>

change endpoint key name

Signed-off-by: William Li <[email protected]>

update go module

Signed-off-by: William Li <[email protected]>
  • Loading branch information
linan-0115 committed May 14, 2024
1 parent dc0d8c3 commit aff3d5f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions velero-plugin-for-gcp/object_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
kmsKeyNameConfigKey = "kmsKeyName"
serviceAccountConfig = "serviceAccount"
credentialsFileConfigKey = "credentialsFile"
storeEndpointConfigKey = "storeEndpoint"
)

// bucketWriter wraps the GCP SDK functions for accessing object store so they can be faked for testing.
Expand Down Expand Up @@ -101,6 +102,7 @@ func (o *ObjectStore) Init(config map[string]string) error {
kmsKeyNameConfigKey,
serviceAccountConfig,
credentialsFileConfigKey,
storeEndpointConfigKey,
); err != nil {
return err
}
Expand Down Expand Up @@ -139,6 +141,11 @@ func (o *ObjectStore) Init(config map[string]string) error {
return errors.WithStack(err)
}

// if using a endpoint, we need to pass it when creating the object store client
if endpoint, ok := config[storeEndpointConfigKey]; ok {
clientOptions = append(clientOptions, option.WithEndpoint(endpoint))
}

if creds.JSON != nil {
o.fileCredType, err = getSecretAccountTypeKey(creds.JSON)
if err != nil {
Expand Down

0 comments on commit aff3d5f

Please sign in to comment.