Added Logger to closing GCP client
Signed-off-by: pa250194 <pa250194@ncr.com>
This commit is contained in:
parent
f62571bcec
commit
f797fbfdf0
|
@ -272,10 +272,9 @@ func (r *BucketReconciler) reconcileWithGCP(ctx context.Context, bucket sourcev1
|
|||
gcpClient, err := r.authGCP(ctx, bucket)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("auth error: %w", err)
|
||||
log.Error(err, "GCP Provider")
|
||||
return sourcev1.BucketNotReady(bucket, sourcev1.AuthenticationFailedReason, err.Error()), err
|
||||
}
|
||||
defer gcpClient.Client.Close()
|
||||
defer gcpClient.Close(log)
|
||||
|
||||
ctxTimeout, cancel := context.WithTimeout(ctx, bucket.Spec.Timeout.Duration)
|
||||
defer cancel()
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
gcpstorage "cloud.google.com/go/storage"
|
||||
"github.com/go-logr/logr"
|
||||
"google.golang.org/api/iterator"
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
@ -162,3 +163,10 @@ func (c *GCPClient) ListObjects(ctx context.Context, bucketName string, query *g
|
|||
items := c.Client.Bucket(bucketName).Objects(ctx, query)
|
||||
return items
|
||||
}
|
||||
|
||||
// Close closes the GCP Client and logs any useful errors
|
||||
func (c *GCPClient) Close(log logr.Logger) {
|
||||
if err := c.Client.Close(); err != nil {
|
||||
log.Error(err, "GCP Provider")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue