Conversation
There was a problem hiding this comment.
Code Review Summary
This PR performs a clean refactoring of the config package code:
✅ Resource Management Improvement: Added defer fs.Close() in pkg/config/sources.go to properly close filesystem handles - excellent catch for preventing resource leaks.
✅ Code Organization: Moving GetUserSettings() from pkg/config to pkg/userconfig as Get() improves package boundaries and cohesion.
✅ Refactoring Quality: The extraction of resolveOne(), resolveDirectory(), and singleSource() helper functions makes the resolution logic more modular and easier to understand.
✅ Simplified Code: The new BuiltinAgentNames() implementation using slices.Sorted(maps.Keys(...)) is cleaner and adds consistent ordering.
✅ Functional Equivalence: All logic changes maintain the same behavior as the original code - URL resolution, OCI handling, and alias resolution all work identically.
No issues found. The code is well-structured and maintains backward compatibility.
Signed-off-by: David Gageot <david.gageot@docker.com>
The function only wraps userconfig.Load() + cfg.GetSettings(), so it belongs in pkg/userconfig rather than pkg/config which is about agent configuration resolution. Renamed to Get() since the package name already provides context. Assisted-By: cagent
Load() now accepts Source directly since every caller already passes a Source. The test helper testfileSource is replaced with the existing NewFileSource(). Assisted-By: cagent
Assisted-By: cagent
ebb2921 to
a6a5fc9
Compare
No description provided.