Skip to content

refactor: move config to user dir#1078

Open
madhavilosetty-intel wants to merge 2 commits into
mainfrom
configUser
Open

refactor: move config to user dir#1078
madhavilosetty-intel wants to merge 2 commits into
mainfrom
configUser

Conversation

@madhavilosetty-intel

Copy link
Copy Markdown
Contributor

No description provided.

@madhavilosetty-intel madhavilosetty-intel requested a review from a team as a code owner June 15, 2026 23:29
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.44%. Comparing base (fe3c5f0) to head (f3350fd).

Files with missing lines Patch % Lines
config/config.go 66.66% 5 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sudhir-intc

Copy link
Copy Markdown
Contributor

@madhavilosetty-intel : could you please add some context to this PR on why this PR is needed. Is it an enhancement or a fix.
Incase of feature/enhancement - could you please link the github issue.
Incase of an issue - what issue is this PR fixing ?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 seedConfig to 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.

Comment thread config/config.go
Comment on lines +264 to +272
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
}
Comment thread config/config_test.go
Comment on lines +70 to +79
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants