Support user config file#203
Conversation
📝 WalkthroughWalkthroughRoxie adopts XDG-compliant user configuration and cache directories, centralizes logger initialization with user config defaults, and updates all command handlers to use a global logger instance. The imagecache module gains error-aware XDG cache directory resolution, deployer handles imagecache initialization errors, and a new tryApplyUserDefaults function merges per-user settings at startup. ChangesUser config and cache integration
CI workflow adjustment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
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 docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a 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 |
97ae030 to
a58fe13
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/deployer/deployer.go (1)
230-245:⚠️ Potential issue | 🟠 Major | ⚡ Quick winClean up
tempDirbefore returning on image cache init failure.If
imagecache.New(...)fails,New(...)returns immediately and leaves the temp directory created earlier on disk. Repeated failures will leak directories.Suggested fix
d.dockerAuth = dockerauth.New(log) d.imageCache, err = imagecache.New(log, "", 20) if err != nil { - return nil, err + _ = os.RemoveAll(tempDir) + return nil, fmt.Errorf("failed to initialize image cache: %w", err) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/deployer/deployer.go` around lines 230 - 245, The tempDir created before initializing the Deployer is not removed if imagecache.New(...) fails, leaking a directory; update the New/constructor path in internal/deployer/deployer.go (around tempDir, Deployer struct init, and the imageCache assignment where imagecache.New is called) to remove the tempDir on error (e.g., call os.RemoveAll(tempDir)) before returning the error so the temporary directory is cleaned up on failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/deploy_test.go`:
- Around line 271-272: The tests currently only set HOME via t.Setenv("HOME",
t.TempDir()), but XDG_CONFIG_HOME can still redirect xdg.UserConfigPath();
update each test instance that sets HOME (the t.Setenv("HOME", t.TempDir())
calls) to also set XDG_CONFIG_HOME to the same temp dir (e.g., add
t.Setenv("XDG_CONFIG_HOME", t.TempDir()) or reuse the same temp dir variable) so
path resolution is deterministic; apply the same change to the other occurrence
noted in the file.
In `@cmd/main.go`:
- Around line 52-55: Do not silently return nil when xdg.UserConfigPath() fails;
instead propagate the error (wrap it) or at minimum log a warning so caller
knows user-config couldn't be resolved. Replace the current branch that does "if
err != nil { return nil }" with code that returns a wrapped error like
fmt.Errorf("resolve user config path: %w", err) (or calls processLogger.Warn/
log.Printf with the error and continues), and ensure the containing function
signature and callers accept/handle the returned error; update imports (fmt or
log) as needed.
- Around line 23-33: globalLogger is declared but only initialized in main(),
causing nil-pointer panics in command handlers like runDeploy and runTeardown
when those functions are invoked outside main(); fix by ensuring globalLogger is
initialized at package load or via a lazy accessor: either set globalLogger =
logger.New() at declaration time (replace the nil pointer declaration) or
implement a getGlobalLogger() that checks if globalLogger==nil and sets it to
logger.New() before returning; update runDeploy/runTeardown to call
getGlobalLogger() (or rely on the package-level initialized globalLogger) so
they never dereference a nil logger.
---
Outside diff comments:
In `@internal/deployer/deployer.go`:
- Around line 230-245: The tempDir created before initializing the Deployer is
not removed if imagecache.New(...) fails, leaking a directory; update the
New/constructor path in internal/deployer/deployer.go (around tempDir, Deployer
struct init, and the imageCache assignment where imagecache.New is called) to
remove the tempDir on error (e.g., call os.RemoveAll(tempDir)) before returning
the error so the temporary directory is cleaned up on failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Enterprise
Run ID: 9a4b55c3-3288-4a61-b134-df6f99d4da73
📒 Files selected for processing (10)
.github/workflows/docker-build.ymlcmd/deploy.gocmd/deploy_test.gocmd/env.gocmd/main.gocmd/teardown.gointernal/deployer/deployer.gointernal/imagecache/imagecache.gointernal/imagecache/imagecache_test.gointernal/xdg/xdg.go
💤 Files with no reviewable changes (1)
- .github/workflows/docker-build.yml
574ab05 to
8500c92
Compare
8500c92 to
3978528
Compare
3978528 to
c996323
Compare
c996323 to
88cd1f0
Compare
Load user defaults from
~/.config/roxie/config.yaml(or$XDG_CONFIG_HOME/roxie/config.yaml) before command execution. The user config overrides hardcoded defaults and is itself overridden by CLI flags.internal/xdgpackage for resolving config and cache directories~/.roxie.image_cacheto~/.cache/roxie/image_cacheglobalLoggercreated inmain(), shared across all commandsImportant use-case: Allow colleagues who are used to certain workflows to configure roxie according to their needs. Specifically thinking about:
So they don't need to keep repeating
roxie deploy --pause-reconciliation --single-namespace.