Support GOBUILDCACHE_ prefixed environment variables#8
Merged
richardartoul merged 5 commits intorichardartoul:mainfrom Feb 6, 2026
Merged
Conversation
Add support for namespaced environment variables with GOBUILDCACHE_ prefix to avoid conflicts with other tools that may use generic names like BACKEND_TYPE, S3_BUCKET, and S3_PREFIX. Changes: - Add getEnvWithPrefix, getEnvBoolWithPrefix, getEnvFloatWithPrefix helpers that check for GOBUILDCACHE_<KEY> first, then fall back to <KEY> - Update all command functions to use the new prefixed helpers - Update help text to document both prefixed and unprefixed forms - Add comprehensive tests for the new helper functions The prefixed version takes precedence if both are set, maintaining full backward compatibility with existing unprefixed environment variables.
- Update usage examples to use GOBUILDCACHE_ prefixed env vars - Add note explaining both prefixed and unprefixed forms are supported - Update configuration table to show both forms for each variable
- Use t.Setenv() for idiomatic test cleanup (Go 1.17+) - Add explicit tests for empty string fallback behavior - Simplify README configuration table for readability - Fix getEnvBoolWithPrefix to properly delegate to getEnvBool
- Document empty prefixed value fallback behavior in README - Update getEnvBoolWithPrefix to fall back to unprefixed on invalid values - Add test for invalid bool value fallback behavior This aligns error handling across all three WithPrefix functions.
richardartoul
approved these changes
Feb 6, 2026
README.md
Outdated
|
|
||
| | Flag | Env Var (`<KEY>`) | Default | Description | | ||
| |------|-------------------|---------|-------------| | ||
| | `-backend` | `BACKEND_TYPE` | `disk` | Backend type: `disk` or `s3` | |
Owner
There was a problem hiding this comment.
can you update these to have the GOBUILDCACHE_ prefix?
Contributor
Author
There was a problem hiding this comment.
Implemented. Updated the README table, all integration tests, and example workflows to use the GOBUILDCACHE_ prefix.
Update all integration tests, example workflows, and README table to use the recommended GOBUILDCACHE_ prefixed environment variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GOBUILDCACHE_prefix to avoid conflicts with other toolsWhy these changes are safe
Full backward compatibility: All existing unprefixed environment variables (
BACKEND_TYPE,S3_BUCKET,S3_PREFIX, etc.) continue to work exactly as before.Precedence is clear: When both
GOBUILDCACHE_<KEY>and<KEY>are set, the prefixed version takes precedence. This allows users to explicitly override values in environments where the unprefixed names might conflict.Graceful fallback: If a prefixed variable is set to an empty string or an invalid value (e.g.,
GOBUILDCACHE_DEBUG=not-a-bool), it falls through to the unprefixed version. This prevents misconfiguration from silently breaking behavior.Comprehensive tests: Added unit tests for all three helper functions covering default values, unprefixed values, prefixed values, precedence behavior, and fallback on empty/invalid values.
Changes
getEnvWithPrefix,getEnvBoolWithPrefix,getEnvFloatWithPrefixhelper functionsrunServerCommand,runClearCommand,runClearLocalCommand,runClearRemoteCommandto use new helpersenv_test.gowith comprehensive testsMotivation
When integrating gobuildcache into CI systems like Confluent's cc-mk-include, using generic environment variable names like
BACKEND_TYPE,S3_BUCKET, andS3_PREFIXcan conflict with other tools. The prefixed form (GOBUILDCACHE_BACKEND_TYPE, etc.) provides proper namespacing while maintaining backward compatibility.Test plan