Skip to content

feat: Determine default metro from profile#224

Merged
nderjung merged 2 commits intostagingfrom
jedevc/default-metro
Apr 22, 2026
Merged

feat: Determine default metro from profile#224
nderjung merged 2 commits intostagingfrom
jedevc/default-metro

Conversation

@jedevc
Copy link
Copy Markdown
Member

@jedevc jedevc commented Mar 23, 2026

So it needs to be manually specified less on create.

The best mechanism for doing with was allowing context.Context on the Fields calls.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.Fields to accept context.Context and update call sites/implementations accordingly.
  • Add Profile.DefaultMetro + GetDefaultMetro() and use it to default MetroName (and run --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.

Comment thread internal/config/profile.go Outdated
Comment thread internal/resource/patch/patch.go Outdated
Comment thread internal/resource/patch/visual.go
Comment thread tools/gendocs/mdx.go Outdated
@jedevc jedevc force-pushed the jedevc/default-metro branch from 8d06de5 to 67ca717 Compare March 23, 2026 17:22
@jedevc jedevc force-pushed the jedevc/default-metro branch from 67ca717 to 5699bc1 Compare April 1, 2026 17:17
@jedevc jedevc force-pushed the jedevc/default-metro branch 2 times, most recently from d7eeea8 to 9725a5a Compare April 16, 2026 14:02
@jedevc jedevc marked this pull request as ready for review April 16, 2026 14:02
@jedevc jedevc requested a review from Copilot April 16, 2026 14:02

This comment was marked as resolved.

@jedevc jedevc force-pushed the jedevc/default-metro branch 2 times, most recently from d5b7d03 to 32cd52c Compare April 16, 2026 14:49
@jedevc jedevc requested a review from nderjung April 16, 2026 14:50
jedevc added 2 commits April 17, 2026 09:48
Signed-off-by: Justin Chadwell <justin@unikraft.com>
Signed-off-by: Justin Chadwell <justin@unikraft.com>
@jedevc jedevc force-pushed the jedevc/default-metro branch from 32cd52c to b465bd1 Compare April 17, 2026 08:50
@jedevc jedevc requested a review from craciunoiuc April 22, 2026 15:41
Copy link
Copy Markdown
Member

@nderjung nderjung left a comment

Choose a reason for hiding this comment

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

Thanks!

Reviewed-by: Alexander Jung alex@unikraft.com
Approved-by: Alexander Jung alex@unikraft.com

@nderjung nderjung merged commit e46f146 into staging Apr 22, 2026
9 checks passed
@nderjung nderjung deleted the jedevc/default-metro branch April 22, 2026 15:50
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.

3 participants