Skip to content

feat(autoconf): auto-mount home config files (e.g. .gitconfig)#445

Merged
feloy merged 2 commits intoopenkaiden:mainfrom
feloy:autoconf-github
May 7, 2026
Merged

feat(autoconf): auto-mount home config files (e.g. .gitconfig)#445
feloy merged 2 commits intoopenkaiden:mainfrom
feloy:autoconf-github

Conversation

@feloy
Copy link
Copy Markdown
Contributor

@feloy feloy commented May 7, 2026

Adds a generic mechanism to detect and mount host home-directory config files read-only into workspace containers via kdn autoconf. Files are registered in a central list (starting with .gitconfig); adding a new one requires only a single entry. Host and container paths are kept separate to handle platform differences on Windows.

Users are offered three config targets (global, project, local), the same flow as for secrets. Already-mounted files are skipped. Fixes a bug where a mount present only in the global config was also reported as present in the project config, because the project loader merges global into its result.

Adds AddMount to ProjectConfigUpdater (idempotent by host+target pair).

Part of #377

@feloy feloy mentioned this pull request May 7, 2026
8 tasks
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds automatic detection and mounting of home directory configuration files into workspace containers. A detector scans for registered config files (currently .gitconfig), the autoconf runner orchestrates confirmation and target selection (global/project/local), and ProjectConfigUpdater persists read-only mounts idempotently in projects.json.

Changes

Home Config Files Auto-mounting

Layer / File(s) Summary
Public Data Contracts
pkg/autoconf/autoconfhomeconfigfiles.go, pkg/config/projectsupdater.go
Adds HomeConfigFilesConfigTarget enum and HomeConfigFilesAutoconfOptions; extends ProjectConfigUpdater with AddMount(projectID, host, target string, ro bool) error.
Home Config Detection
pkg/autoconf/detecthomeconfigfiles.go, pkg/autoconf/detecthomeconfigfiles_test.go
Detector resolves host home directory, iterates registered specs (e.g. .gitconfig), checks existence via injected stat, and returns DetectedHomeConfigFile entries with both host and container paths; tests cover presence/absence, multi-spec filtering, stat errors, empty specs, and divergent host/container paths.
Autoconf Runner Orchestration
pkg/autoconf/autoconfhomeconfigfiles.go
Runner detects files, finds existing mounts across global/project/local configs, optionally confirms, selects recording target (global/project/local), validates required collaborators (projectID/workspace updater), and applies mounts via ProjectConfigUpdater or WorkspaceUpdater; includes helpers for existing-location detection and formatting.
Runner Test Suite
pkg/autoconf/autoconfhomeconfigfiles_test.go
Comprehensive tests for no-files, --yes global apply, confirm+local/project apply, decline/skip flows, already-mounted detection across scopes, option filtering, missing-updater/projectID validation, and detector error propagation.
Mount Persistence
pkg/config/projectsupdater.go, pkg/config/projectsupdater_test.go
Implements AddMount: reads projects.json, ensures Mounts slice, idempotently appends workspace.Mount keyed by host+target (stores Ro as pointer), and writes back; tests validate creation, idempotency, project-scoped isolation, accumulation, and error propagation.
CLI Wiring
pkg/cmd/autoconf.go, pkg/cmd/autoconf_test.go, pkg/autoconf/autoconf_test.go
autoconfCmd gains detector, projectLoader, and selectTarget callback; preRun initializes project loader and detector/selector defaults; run invokes HomeConfigFilesAutoconf when detector present; test doubles updated with AddMount stubs.
Documentation
.agents/skills/working-with-autoconf/SKILL.md, AGENTS.md, README.md
Adds SKILL.md section detailing home-config detection and mounting flow, documents registeredHomeConfigFiles host/container path distinction, AGENTS.md documents ProjectConfigUpdater AddMount, and README shows mounting example for $HOME/.gitconfig.
Build / Makefile
Makefile
Relocates GOFILES and broadens fmt/check-fmt to run gofmt over the entire repository (gofmt -w . / gofmt -l .).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • openkaiden/kdn#379: Introduced earlier autoconf framework and updater interfaces that this PR extends with HomeConfigFiles detector/runner and AddMount.
  • openkaiden/kdn#435: Related autoconf extension that also wires mount-target selection and AddMount into CLI/updaters.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature: auto-mounting home config files like .gitconfig via autoconf.
Description check ✅ Passed The description comprehensively explains the feature, implementation approach, user flow, bug fixes, and related changes, all directly relevant to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@pkg/autoconf/autoconfhomeconfigfiles_test.go`:
- Around line 104-106: The helper function alwaysGlobalHomeConfig is currently
unused and triggers a golangci-lint "unused" error; either remove the function
alwaysGlobalHomeConfig entirely from
pkg/autoconf/autoconfhomeconfigfiles_test.go, or replace one of the existing
inline lambdas used in tests with this named function (i.e., pass
alwaysGlobalHomeConfig where a
HomeConfigFilesConfigTargetOption->HomeConfigFilesConfigTarget selection is
required) so it becomes referenced; update imports if necessary after removal.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ebec183a-e0bf-4a74-aed4-5de24dd3b7fa

📥 Commits

Reviewing files that changed from the base of the PR and between 8403c1f and 58af731.

📒 Files selected for processing (12)
  • .agents/skills/working-with-autoconf/SKILL.md
  • AGENTS.md
  • README.md
  • pkg/autoconf/autoconf_test.go
  • pkg/autoconf/autoconfhomeconfigfiles.go
  • pkg/autoconf/autoconfhomeconfigfiles_test.go
  • pkg/autoconf/detecthomeconfigfiles.go
  • pkg/autoconf/detecthomeconfigfiles_test.go
  • pkg/cmd/autoconf.go
  • pkg/cmd/autoconf_test.go
  • pkg/config/projectsupdater.go
  • pkg/config/projectsupdater_test.go

Comment thread pkg/autoconf/autoconfhomeconfigfiles_test.go Outdated
@feloy feloy force-pushed the autoconf-github branch from 58af731 to 4cd6978 Compare May 7, 2026 08:08
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 45 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/cmd/autoconf.go 42.85% 22 Missing and 2 partials ⚠️
pkg/autoconf/autoconfhomeconfigfiles.go 88.18% 8 Missing and 5 partials ⚠️
pkg/autoconf/detecthomeconfigfiles.go 68.00% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@feloy feloy changed the title feat(autoconf): auto-mount home config files (e.g. .gitconfig) feat(autoconf): auto-mount home config files (e.g. .gitconfig) May 7, 2026
feloy and others added 2 commits May 7, 2026 10:48
Adds a generic mechanism to detect and mount host home-directory config
files read-only into workspace containers via `kdn autoconf`. Files are
registered in a central list (starting with .gitconfig); adding a new
one requires only a single entry. Host and container paths are kept
separate to handle platform differences on Windows.

Users are offered three config targets (global, project, local), the
same flow as for secrets. Already-mounted files are skipped. Fixes a
bug where a mount present only in the global config was also reported
as present in the project config, because the project loader merges
global into its result.

Adds AddMount to ProjectConfigUpdater (idempotent by host+target pair).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
@feloy feloy force-pushed the autoconf-github branch from f1d7cea to b6c4af8 Compare May 7, 2026 08:48
@feloy feloy merged commit 63a5fe0 into openkaiden:main May 7, 2026
7 of 9 checks passed
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.

2 participants