Add pkg/vmcp/cli/init.go for vMCP config scaffolding#4903
Conversation
There was a problem hiding this comment.
Pull request overview
Adds vMCP config scaffolding support to the pkg/vmcp/cli package, enabling generation of a commented starter YAML config by discovering workloads in a ToolHive group and writing the result to a file or writer.
Changes:
- Introduce
Init(ctx, InitConfig)to discover group workloads via an injectedworkloads.Discovererand render a commented YAML starter config. - Implement output routing to either an
io.Writer(stdout-style) or a file written with0o600permissions. - Add unit tests for writer/file output, empty groups, nil-backend skipping, discovery errors, YAML load+validate, file permissions, and input validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/vmcp/cli/init.go | Implements workload discovery, YAML template rendering, and output writing for thv vmcp init scaffolding. |
| pkg/vmcp/cli/init_test.go | Adds unit test coverage for init scaffolding behavior and output validity/permissions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4903 +/- ##
==========================================
- Coverage 69.25% 69.22% -0.04%
==========================================
Files 537 538 +1
Lines 55380 55452 +72
==========================================
+ Hits 38354 38385 +31
- Misses 14080 14117 +37
- Partials 2946 2950 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
PR size has been reduced below the XL threshold. Thank you for splitting this up!
|
✅ PR size has been reduced below the XL threshold. The size review has been dismissed and this PR can now proceed with normal review. Thank you for splitting this up! |
Implement Init(ctx, InitConfig) which discovers running workloads in a named ToolHive group via an injected Discoverer, renders a commented starter YAML config pre-populated with one backend entry per accessible workload, and writes the result to a file (0o600) or an io.Writer. Workloads returning nil from GetWorkloadAsVMCPBackend are skipped with a debug log. Empty groups produce a valid YAML skeleton with backends: []. Includes unit tests covering writer output, file output, nil-backend skipping, empty groups, discovery errors, YAML validity (loader + validator), file permissions, and input validation edge cases. Closes #4882
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pkg/vmcp/cli/init.go:222
- When writing to an arbitrary
io.Writer,Writeis allowed to return a short write with a nil error. Currently the code ignores the returned byte count, so it could silently truncate output. Consider usingio.Copyfrom abytes.Reader(or explicitly checkingn == len(content)and returningio.ErrShortWriteotherwise).
return nil
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Implement Init(ctx, InitConfig) which discovers running workloads in a named ToolHive group via an injected Discoverer, renders a commented starter YAML config pre-populated with one backend entry per accessible workload, and writes the result to a file (0o600) or an io.Writer.
Workloads returning nil from GetWorkloadAsVMCPBackend are skipped with a debug log. Empty groups produce a valid YAML skeleton with backends: [].
Includes unit tests covering writer output, file output, nil-backend skipping, empty groups, discovery errors, YAML validity (loader + validator), file permissions, and input validation edge cases.
Fixes #4882
Type of change
Test plan
task test)task test-e2e)task lint-fix)Changes
Does this introduce a user-facing change?
Implementation plan
Approved implementation plan
Special notes for reviewers