feat: Add Windows-specific default config file paths#5073
feat: Add Windows-specific default config file paths#5073coatico wants to merge 3 commits intoprometheus:mainfrom
Conversation
55a0855 to
7bdf6c7
Compare
|
tried to test locally: |
fcdab67 to
bfdd117
Compare
📝 WalkthroughWalkthroughThis PR implements OS-specific default configuration file paths for amtool. It replaces hard-coded Unix paths with platform-aware logic: non-Windows systems use Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cli/root_others_test.go (1)
24-78: LGTM - Tests cover key scenarios for non-Windows paths.Both test functions properly validate the default behavior and
XDG_CONFIG_DIRSoverride. Usingt.Setenvensures clean environment restoration.Consider adding a test case where
XDG_CONFIG_HOMEis set to a non-empty value to verifyos.UserConfigDir()respects it:💡 Optional test case for XDG_CONFIG_HOME
func TestDefaultConfigFilesOthersWithXDGConfigHome(t *testing.T) { home := t.TempDir() customConfigHome := t.TempDir() t.Setenv("HOME", home) t.Setenv("XDG_CONFIG_HOME", customConfigHome) t.Setenv("XDG_CONFIG_DIRS", "") files := defaultConfigFiles() if len(files) != 2 { t.Fatalf("expected 2 config file paths, got %d", len(files)) } expectedUser := filepath.Join(customConfigHome, "amtool", "config.yml") if files[0] != expectedUser { t.Errorf("expected user config path %q, got %q", expectedUser, files[0]) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cli/root_others_test.go` around lines 24 - 78, Add a test to cover the case when XDG_CONFIG_HOME is set: create a new test (e.g., TestDefaultConfigFilesOthersWithXDGConfigHome) that uses t.TempDir() for HOME and another temp dir for custom XDG_CONFIG_HOME, set t.Setenv("HOME", home) and t.Setenv("XDG_CONFIG_HOME", customConfigHome") and t.Setenv("XDG_CONFIG_DIRS", ""), call defaultConfigFiles(), assert len(files)==2 and that files[0] equals filepath.Join(customConfigHome, "amtool", "config.yml"); reference the existing tests TestDefaultConfigFilesOthers and TestDefaultConfigFilesOthersWithXDGConfigDirs and the function defaultConfigFiles to locate where to add this case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cli/root_others_test.go`:
- Around line 24-78: Add a test to cover the case when XDG_CONFIG_HOME is set:
create a new test (e.g., TestDefaultConfigFilesOthersWithXDGConfigHome) that
uses t.TempDir() for HOME and another temp dir for custom XDG_CONFIG_HOME, set
t.Setenv("HOME", home) and t.Setenv("XDG_CONFIG_HOME", customConfigHome") and
t.Setenv("XDG_CONFIG_DIRS", ""), call defaultConfigFiles(), assert len(files)==2
and that files[0] equals filepath.Join(customConfigHome, "amtool",
"config.yml"); reference the existing tests TestDefaultConfigFilesOthers and
TestDefaultConfigFilesOthersWithXDGConfigDirs and the function
defaultConfigFiles to locate where to add this case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: facfa22c-eae6-48ca-ac6f-9f6385f1097e
📒 Files selected for processing (5)
cli/root.gocli/root_others.gocli/root_others_test.gocli/root_windows.gocli/root_windows_test.go
Signed-off-by: VAN LINT <9860220+coatico@users.noreply.github.com>
Pull Request Checklist
Please check all the applicable boxes.
Which user-facing changes does this PR introduce?
Summary by CodeRabbit
Chores
Tests