feat: Determine default metro from profile#224
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the resource field-schema pipeline to be context-aware and uses the active config profile to infer a default metro (so users need to manually specify a metro less often during create/run flows).
Changes:
- Extend
resource.Resource.Fieldsto acceptcontext.Contextand update call sites/implementations accordingly. - Add
Profile.DefaultMetro+GetDefaultMetro()and use it to defaultMetroName(andrun --metro) from the current profile. - Adjust patch/visual-edit behavior to better preserve defaults during create flows.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/gendocs/mdx.go | Updates doc generation to call Fields with a context (currently uses context.Background()). |
| tools/gendocs/man.go | Updates manpage generation to call Fields with a context. |
| internal/resource/value/compare.go | Adds value.IsZero helper for zero-value detection. |
| internal/resource/tui/panel_list.go | Threads panel context into Fields calls. |
| internal/resource/tui/panel_detail.go | Threads panel context into Fields calls. |
| internal/resource/testing/resource.go | Updates test resource to the new Fields(ctx) signature. |
| internal/resource/sandbox.go | Passes caller context into Fields when adding to sandbox. |
| internal/resource/resource.go | Changes Resource.Fields interface to Fields(ctx context.Context). |
| internal/resource/patch/visual_test.go | Updates tests for the new Fields(ctx) signature. |
| internal/resource/patch/visual.go | Changes create/edit visual patch retention rules (defaults vs removals). |
| internal/resource/patch/patch.go | Changes patch generation to preserve non-zero defaults (needs scoping to create). |
| internal/resource/cmd/sort.go | Passes command context into Fields for sorting/validation. |
| internal/resource/cmd/resolve.go | Passes command context into Fields during resolution. |
| internal/resource/cmd/printers.go | Passes command context into Fields for all output formats. |
| internal/resource/cmd/cmd_test.go | Updates tests to pass context into Fields. |
| internal/resource/cmd/cmd.go | Uses Fields(ctx) and moves required-field validation before dry-run printing. |
| internal/config/profile.go | Adds DefaultMetro and GetDefaultMetro() helper. |
| internal/cmd/volumes.go | Defaults MetroName from current profile during field generation. |
| internal/cmd/services.go | Defaults MetroName from current profile during field generation. |
| internal/cmd/run.go | Makes --metro optional and falls back to profile default when absent; uses Fields(ctx). |
| internal/cmd/profile.go | Updates to Fields(ctx) signature. |
| internal/cmd/metros.go | Updates to Fields(ctx) signature. |
| internal/cmd/instances.go | Defaults MetroName from current profile during field generation. |
| internal/cmd/images.go | Updates to Fields(ctx) signature. |
| internal/cmd/certificates.go | Defaults MetroName from current profile during field generation. |
| internal/cmd/any.go | Updates to Fields(ctx) signature and threads ctx to underlying resource. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d06de5 to
67ca717
Compare
67ca717 to
5699bc1
Compare
d7eeea8 to
9725a5a
Compare
d5b7d03 to
32cd52c
Compare
Signed-off-by: Justin Chadwell <justin@unikraft.com>
Signed-off-by: Justin Chadwell <justin@unikraft.com>
32cd52c to
b465bd1
Compare
nderjung
approved these changes
Apr 22, 2026
Member
nderjung
left a comment
There was a problem hiding this comment.
Thanks!
Reviewed-by: Alexander Jung alex@unikraft.com
Approved-by: Alexander Jung alex@unikraft.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So it needs to be manually specified less on create.
The best mechanism for doing with was allowing
context.Contexton theFieldscalls.