refactor: move config to user dir#1078
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1078 +/- ##
==========================================
+ Coverage 43.39% 43.44% +0.04%
==========================================
Files 141 141
Lines 13397 13419 +22
==========================================
+ Hits 5814 5830 +16
- Misses 7022 7026 +4
- Partials 561 563 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@madhavilosetty-intel : could you please add some context to this PR on why this PR is needed. Is it an enhancement or a fix. |
There was a problem hiding this comment.
Pull request overview
Moves the tray-mode configuration file into the per-user config directory (aligned with where the embedded SQLite DB lives) and adds a one-time migration path so installer-provisioned credentials carry over on first tray launch.
Changes:
- Update config-path resolution so tray mode prefers
<UserConfigDir>/device-management-toolkit/config.yml, otherwise fall back beside the binary. - Add
seedConfigto copy an installer-provisioned config into the per-user location on first tray run. - Add unit tests covering config path resolution and seeding behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
config/config.go |
Adds per-user config path resolution for tray mode and seeds per-user config from beside-binary config. |
config/config_test.go |
Adds tests for tray/non-tray config path resolution and for seedConfig behavior. |
| func seedConfig(src, dst string) error { | ||
| if _, err := os.Stat(dst); err == nil { | ||
| return nil | ||
| } | ||
|
|
||
| data, err := os.ReadFile(src) | ||
| if err != nil { | ||
| return nil //nolint:nilerr // no installer config to migrate (e.g. dev run); init proceeds normally | ||
| } |
| func TestResolveConfigPath_FlagWins(t *testing.T) { //nolint:paralleltest // mutates package-global TrayMode | ||
| orig := TrayMode | ||
| TrayMode = true | ||
|
|
||
| defer func() { TrayMode = orig }() | ||
|
|
||
| got, err := resolveConfigPath("/custom/path.yml") | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, "/custom/path.yml", got) | ||
| } |
No description provided.