From aff3d5f6dacd1eaaeab69e68a399d69403b51c02 Mon Sep 17 00:00:00 2001 From: William Li Date: Thu, 9 May 2024 16:21:46 +0800 Subject: [PATCH] add endpoint for GCP objectstore client add endpoint for GCP objectstore client Signed-off-by: William Li sign off Signed-off-by: William Li format code Signed-off-by: William Li remove wrong files Signed-off-by: William Li update go module Signed-off-by: William Li change endpoint key name Signed-off-by: William Li update go module Signed-off-by: William Li --- velero-plugin-for-gcp/object_store.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/velero-plugin-for-gcp/object_store.go b/velero-plugin-for-gcp/object_store.go index 1cdf37a..87749df 100644 --- a/velero-plugin-for-gcp/object_store.go +++ b/velero-plugin-for-gcp/object_store.go @@ -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. @@ -101,6 +102,7 @@ func (o *ObjectStore) Init(config map[string]string) error { kmsKeyNameConfigKey, serviceAccountConfig, credentialsFileConfigKey, + storeEndpointConfigKey, ); err != nil { return err } @@ -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 {