[PR #815] [MERGED] refactor: use reflection to mark file based env variables #615

Closed
opened 2025-10-09 16:53:46 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/pocket-id/pocket-id/pull/815
Author: @stonith404
Created: 8/7/2025
Status: Merged
Merged: 8/7/2025
Merged by: @stonith404

Base: mainHead: refactor/file-based-env-variables


📝 Commits (6)

  • 38b7e36 refactor: use reflection to mark file based env variables
  • 222f7ae fix linter issues
  • d1ccf92 fix unit test
  • 61db90c handle files containing binary for encryption key correctly
  • b914906 trim whitespaces for non binary files
  • bfcb510 fix unit test

📊 Changes

3 files changed (+210 additions, -82 deletions)

View changed files

📝 backend/internal/cmds/key_rotate_test.go (+1 -1)
📝 backend/internal/common/env_config.go (+91 -80)
📝 backend/internal/common/env_config_test.go (+118 -1)

📄 Description

These changes make it simpler to set up environment variables that can be read from a file. This also helps avoid mistakes, like when a developer might accidentally try to access MaxMindLicenseKeyFile instead of MaxMindLicenseKey in the code.

Now, you can use options:"file" to mark environment variables. When marked this way, Pocket ID will try to read from ANY_ENV_VARIABLE_FILE instead of ANY_ENV_VARIABLE. If the file version isn't defined, it will use ANY_ENV_VARIABLE as a fallback.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/pocket-id/pocket-id/pull/815 **Author:** [@stonith404](https://github.com/stonith404) **Created:** 8/7/2025 **Status:** ✅ Merged **Merged:** 8/7/2025 **Merged by:** [@stonith404](https://github.com/stonith404) **Base:** `main` ← **Head:** `refactor/file-based-env-variables` --- ### 📝 Commits (6) - [`38b7e36`](https://github.com/pocket-id/pocket-id/commit/38b7e36eb0e152280f82ac8c3be207dad787306b) refactor: use reflection to mark file based env variables - [`222f7ae`](https://github.com/pocket-id/pocket-id/commit/222f7ae7a1c4b3d810b3c69c885a2ca8f2d9a1a2) fix linter issues - [`d1ccf92`](https://github.com/pocket-id/pocket-id/commit/d1ccf92395ccb42985cbf32ddef263578f400953) fix unit test - [`61db90c`](https://github.com/pocket-id/pocket-id/commit/61db90c0022f81f071067abaa1d7acee16f494d2) handle files containing binary for encryption key correctly - [`b914906`](https://github.com/pocket-id/pocket-id/commit/b9149062db9e39d98b5bd7802ae1bb7797dff1a3) trim whitespaces for non binary files - [`bfcb510`](https://github.com/pocket-id/pocket-id/commit/bfcb510745fe24bad5c57da99c43a9adbb5f19ad) fix unit test ### 📊 Changes **3 files changed** (+210 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `backend/internal/cmds/key_rotate_test.go` (+1 -1) 📝 `backend/internal/common/env_config.go` (+91 -80) 📝 `backend/internal/common/env_config_test.go` (+118 -1) </details> ### 📄 Description These changes make it simpler to set up environment variables that can be read from a file. This also helps avoid mistakes, like when a developer might accidentally try to access `MaxMindLicenseKeyFile` instead of `MaxMindLicenseKey` in the code. Now, you can use `options:"file"` to mark environment variables. When marked this way, Pocket ID will try to read from `ANY_ENV_VARIABLE_FILE` instead of `ANY_ENV_VARIABLE`. If the file version isn't defined, it will use `ANY_ENV_VARIABLE` as a fallback. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-09 16:53:46 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-2#615