Skip to content
This repository has been archived by the owner on Feb 11, 2025. It is now read-only.

Commit

Permalink
Fix GCS credentials when no endpoint specified (#138)
Browse files Browse the repository at this point in the history
* GCS: Use default HTTP client when endpoint is not set. Fixes #137.

* Updated changelog with #138.

Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
  • Loading branch information
atombender and kakkoyun authored Sep 15, 2020
1 parent a8b73bd commit c6fa146
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Fixed Anonymous Credentials Error on public buckets
- [#133](https://github.com/meltwater/drone-cache/pull/133) bacnkend/s3: Fixed Anonymous Credentials Error on public buckets.
- Fixes [#132](https://github.com/meltwater/drone-cache/issues/132)
- [#135](https://github.com/meltwater/drone-cache/issues/135) Fixed parsing of GCS JSON key.
- [#138](https://github.com/meltwater/drone-cache/pull/138) backend/gcs: Fix GCS to pass credentials correctly when `GCS_ENDPOINT` is not set.
- [#135](https://github.com/meltwater/drone-cache/issues/135) backend/gcs: Fixed parsing of GCS JSON key.

### Added

Expand Down
14 changes: 7 additions & 7 deletions storage/backend/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ func New(l log.Logger, c Config) (*Backend, error) {

if c.Endpoint != "" {
opts = append(opts, option.WithEndpoint(c.Endpoint))
}

if !strings.HasPrefix(c.Endpoint, "https://") { // This is not settable from outside world, only used for mock tests.
opts = append(opts, option.WithHTTPClient(&http.Client{Transport: &http.Transport{
// ignore unverified/expired SSL certificates for tests.
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
}}))
if !strings.HasPrefix(c.Endpoint, "https://") { // This is not settable from outside world, only used for mock tests.
opts = append(opts, option.WithHTTPClient(&http.Client{Transport: &http.Transport{
// ignore unverified/expired SSL certificates for tests.
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
}}))
}
}

setAuthenticationMethod(l, c, opts)
opts = setAuthenticationMethod(l, c, opts)

ctx, cancel := context.WithTimeout(context.Background(), c.Timeout)
defer cancel()
Expand Down

0 comments on commit c6fa146

Please sign in to comment.