[PR #1925] [MERGED] Add environment variable support for all configuration options #1945

Closed
opened 2026-03-03 12:36:55 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fsouza/fake-gcs-server/pull/1925
Author: @ota2000
Created: 3/7/2025
Status: Merged
Merged: 2/14/2026
Merged by: @fsouza

Base: mainHead: feature/env-var-configuration


📝 Commits (10+)

  • f33a671 feat: add environment variable support for all configuration options
  • ddb7641 test: add test for environment variable handling with invalid port value type
  • 8817d9a docs: update README to include environment variable configuration for server flags
  • 4c066fb Fix line breaks in README.md
  • 04ef8e5 Remove volume mount from docker run example
  • 8e7df30 refactor: rename envVarOrDefaultT to envVarOrDefault for clarity
  • 5532a7d Merge branch 'feature/env-var-configuration' of https://github.com/ota2000/fake-gcs-server into feature/env-var-configuration
  • 08e8860 test: enhance TestEnvVarOrDefault with uint parsing and validation
  • df84061 refactor: rename variables for environment port configuration for clarity
  • c8bda94 Update Docker command in README.md

📊 Changes

3 files changed (+366 additions, -26 deletions)

View changed files

📝 README.md (+23 -0)
📝 internal/config/config.go (+81 -24)
📝 internal/config/config_test.go (+262 -2)

📄 Description

This PR adds environment variable support for all configuration options in fake-gcs-server. This is particularly useful when running the server in containerized environments like GitHub Actions service containers.

Changes

  • Added environment variable support for all configuration flags
    • I've checked all available flags using docker run --rm fsouza/fake-gcs-server:1.52.2 -help and implemented environment variable support for all configuration options
  • Added a generic helper function envVarOrDefault that returns the environment variable value if set, otherwise the default value, supporting string and uint types
  • Environment variables follow the pattern FAKE_GCS_* (e.g., FAKE_GCS_PORT for -port)
  • Default values are used when environment variables are not set or invalid
  • Maintains backward compatibility with command-line flags

Testing

  • All existing tests pass
  • Added test coverage for environment variable handling
  • Manually tested in containerized environment

I've prepared a custom image with these changes at https://hub.docker.com/repository/docker/ota1200/fake-gcs-server/general and tested it in a production-like environment.
I'll delete this custom image when this PR is released.


🔄 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/fsouza/fake-gcs-server/pull/1925 **Author:** [@ota2000](https://github.com/ota2000) **Created:** 3/7/2025 **Status:** ✅ Merged **Merged:** 2/14/2026 **Merged by:** [@fsouza](https://github.com/fsouza) **Base:** `main` ← **Head:** `feature/env-var-configuration` --- ### 📝 Commits (10+) - [`f33a671`](https://github.com/fsouza/fake-gcs-server/commit/f33a671997319333fd7322f99f22d1e29749c9df) feat: add environment variable support for all configuration options - [`ddb7641`](https://github.com/fsouza/fake-gcs-server/commit/ddb7641d32fc453e61d2c4769fe4ba0f448a0541) test: add test for environment variable handling with invalid port value type - [`8817d9a`](https://github.com/fsouza/fake-gcs-server/commit/8817d9ac11644032e446d5ac982707122233c990) docs: update README to include environment variable configuration for server flags - [`4c066fb`](https://github.com/fsouza/fake-gcs-server/commit/4c066fb601518b00974352c88689e9ae2f3a7afe) Fix line breaks in README.md - [`04ef8e5`](https://github.com/fsouza/fake-gcs-server/commit/04ef8e526b6e65d022043e9f6ace7aaa23936dfe) Remove volume mount from docker run example - [`8e7df30`](https://github.com/fsouza/fake-gcs-server/commit/8e7df30fe041b709d0202c14cf677c75058536ee) refactor: rename envVarOrDefaultT to envVarOrDefault for clarity - [`5532a7d`](https://github.com/fsouza/fake-gcs-server/commit/5532a7d3b937477f2e55cb53e547e70e041e3426) Merge branch 'feature/env-var-configuration' of https://github.com/ota2000/fake-gcs-server into feature/env-var-configuration - [`08e8860`](https://github.com/fsouza/fake-gcs-server/commit/08e88604b767d2bee4f88d2e26b333f5b1704884) test: enhance TestEnvVarOrDefault with uint parsing and validation - [`df84061`](https://github.com/fsouza/fake-gcs-server/commit/df840617ca0ad62437a2555861ab0bb19c2337c0) refactor: rename variables for environment port configuration for clarity - [`c8bda94`](https://github.com/fsouza/fake-gcs-server/commit/c8bda941bedf32f8134e1326161265ee451d3122) Update Docker command in README.md ### 📊 Changes **3 files changed** (+366 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+23 -0) 📝 `internal/config/config.go` (+81 -24) 📝 `internal/config/config_test.go` (+262 -2) </details> ### 📄 Description This PR adds environment variable support for all configuration options in fake-gcs-server. This is particularly useful when running the server in containerized environments like GitHub Actions service containers. ## Changes - Added environment variable support for all configuration flags - I've checked all available flags using `docker run --rm fsouza/fake-gcs-server:1.52.2 -help` and implemented environment variable support for all configuration options - Added a generic helper function `envVarOrDefault` that returns the environment variable value if set, otherwise the default value, supporting string and uint types - Environment variables follow the pattern `FAKE_GCS_*` (e.g., `FAKE_GCS_PORT` for `-port`) - Default values are used when environment variables are not set or invalid - Maintains backward compatibility with command-line flags ## Related Issues/PRs - #561 - Continues the work from #1608 ## Testing - All existing tests pass - Added test coverage for environment variable handling - Manually tested in containerized environment I've prepared a custom image with these changes at https://hub.docker.com/repository/docker/ota1200/fake-gcs-server/general and tested it in a production-like environment. I'll delete this custom image when this PR is released. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 12:36:55 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#1945
No description provided.