google / go-cloud

The Go Cloud Development Kit (Go CDK): A library and tools for open cloud development in Go.
https://gocloud.dev/
Apache License 2.0
9.45k stars 799 forks source link

docstore/mongodocstore: Update Mongo dialer when MONGO_SERVER_URL rotates #3429

Closed concaf closed 2 months ago

concaf commented 2 months ago

Prior to this commit, the dialer for MongoDB was generated once from MONGO_SERVER_URL environment variable but was never updated even when the environment variable was updated in subsequent calls. While this works fine when MONGO_SERVER_URL is not expected to update, but as MONGO_SERVER_URL also contains the credentials to connect to MongoDB, it's a fairly common use case to rotate these credentials (and hence the environment variable) at regular intervals.

This commit fixes that and updates the dialer when MONGO_SERVER_URL is updated.

This PR blocks https://github.com/tektoncd/chains/issues/1089

concaf commented 2 months ago

@vangent thanks for the quick review 🚀 🙂 - i've updated the PR and also added some tests.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 73.20%. Comparing base (3f641fd) to head (024ea8c).

Files Patch % Lines
docstore/mongodocstore/urls.go 81.81% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3429 +/- ## ========================================== + Coverage 73.17% 73.20% +0.03% ========================================== Files 113 113 Lines 14872 14873 +1 ========================================== + Hits 10882 10888 +6 + Misses 3216 3213 -3 + Partials 774 772 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.