Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Private" Environment Variables #103

Merged
merged 3 commits into from
Apr 11, 2024
Merged

Conversation

peterallenwebb
Copy link
Contributor

@peterallenwebb peterallenwebb commented Apr 10, 2024

Description

Support environment variables with a DBT_ENV_PRIVATE_ prefix, which dbt can see, but user code cannot.

Checklist

@peterallenwebb peterallenwebb requested a review from a team as a code owner April 10, 2024 03:04
Copy link

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.60%. Comparing base (80afe5e) to head (2520bfb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
+ Coverage   55.53%   55.60%   +0.07%     
==========================================
  Files          50       50              
  Lines        3065     3070       +5     
==========================================
+ Hits         1702     1707       +5     
  Misses       1363     1363              
Flag Coverage Δ
unit 55.60% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@property
def env_private(self) -> Mapping[str, str]:
return self._env_private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like that we have to keep changing this class and want to get to something that follows the open/closed principle instead, but this should do for the present purpose.

self._env_secrets: Optional[List[str]] = None
self._env_private = {
k[len(PRIVATE_ENV_PREFIX) :]: v
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the motivation for stripping the prefix off of private envs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My take is that it makes them less annoying and verbose to look up later, but I could go either way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could go either way as well, generally anti-'magic' but this feels pretty minimal. Is there a good spot we can document the look up pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even the need to document it tilts me to the side of just keeping the prefix, so I'll just do it that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@peterallenwebb peterallenwebb added this pull request to the merge queue Apr 11, 2024
Merged via the queue into main with commit 05c24e4 Apr 11, 2024
17 checks passed
@peterallenwebb peterallenwebb deleted the paw/private-env-vars branch April 11, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants