Fix rad init to always create bicepconfig.json and remove prompt#11772
Fix rad init to always create bicepconfig.json and remove prompt#11772
Conversation
…icep, warn on existing config Agent-Logs-Url: https://github.com/radius-project/radius/sessions/501b2ffa-3885-4125-99fc-75725464c1c1 Co-authored-by: zachcasper <30731731+zachcasper@users.noreply.github.com>
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/501b2ffa-3885-4125-99fc-75725464c1c1 Co-authored-by: zachcasper <30731731+zachcasper@users.noreply.github.com>
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/9a66910e-d878-4ed9-b3c8-0d0e2e946229 Co-authored-by: zachcasper <30731731+zachcasper@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Unit Tests 2 files ± 0 420 suites ±0 7m 3s ⏱️ +24s Results for commit 10f8e1d. ± Comparison against base commit 8ad0d19. This pull request removes 19 and adds 9 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11772 +/- ##
==========================================
+ Coverage 51.19% 51.25% +0.06%
==========================================
Files 715 712 -3
Lines 45081 45000 -81
==========================================
- Hits 23079 23066 -13
+ Misses 19803 19750 -53
+ Partials 2199 2184 -15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/5f632f25-bb79-4486-b7ec-444c14391048 Co-authored-by: zachcasper <30731731+zachcasper@users.noreply.github.com>
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/5f632f25-bb79-4486-b7ec-444c14391048 Co-authored-by: zachcasper <30731731+zachcasper@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates rad init to always scaffold bicepconfig.json (without prompting) and to avoid corrupting the Bubble Tea progress UI by silencing Helm install info logs, with added unit tests for newly covered branches.
Changes:
- Replace “scaffold application” prompt/flow with unconditional
bicepconfig.jsonscaffolding and a post-run warning when the file already exists. - Add
ClusterOptions.Loggerhook to route/silence Helm informational messages during interactive UI runs. - Add/adjust unit tests to cover new branches and previously uncovered paths.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/setup/application.go | Replace ScaffoldApplication with ScaffoldBicepConfig returning (existed, err) |
| pkg/cli/setup/application_test.go | Update/add tests for ScaffoldBicepConfig creation, preservation, and error branches |
| pkg/cli/helm/cluster.go | Add ClusterOptions.Logger + logf; route select install messages through it |
| pkg/cli/helm/clusteroptions_test.go | New tests covering ClusterOptions.logf (custom logger vs nil) |
| pkg/cli/cmd/radinit/options.go | Remove application options from rad init option model |
| pkg/cli/cmd/radinit/options_test.go | Remove application prompt expectations from option-entry tests |
| pkg/cli/cmd/radinit/init.go | Always scaffold bicepconfig.json; silence Helm info logging during progress UI; warn if file existed |
| pkg/cli/cmd/radinit/init_test.go | Add tests for “bicepconfig exists” warning and InstallRadius error propagation |
| pkg/cli/cmd/radinit/display.go | Update summary/progress UI to show “Create bicepconfig.json” step |
| pkg/cli/cmd/radinit/display_test.go | Update expected UI strings for the new bicepconfig step |
| pkg/cli/cmd/radinit/application.go | Remove application prompt/name entry logic |
| pkg/cli/cmd/radinit/application_test.go | Remove tests for deleted application prompt/name logic |
Comments suppressed due to low confidence (1)
pkg/cli/cmd/radinit/init.go:263
- On the InstallRadius error path, Run returns immediately while the progress UI goroutine(s) are still running. Because progressChan is never closed, the goroutine inside showProgress that ranges over progressChan can block forever, and the UI may keep running after Run returns. Ensure error paths (and ideally the success path) cancel/terminate the progress UI and close progressChan (or make showProgress exit on ctx.Done) to avoid goroutine leaks.
err := r.HelmInterface.InstallRadius(ctx, clusterOptions, r.Options.Cluster.Context)
if err != nil {
return clierrors.MessageWithCause(err, "Failed to install Radius.")
}
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zach Casper <zachcasper@microsoft.com>
…splay Agent-Logs-Url: https://github.com/radius-project/radius/sessions/23a78e3b-db8f-4d7c-a3aa-4a3cd5ffd8d6 Co-authored-by: zachcasper <30731731+zachcasper@users.noreply.github.com>
Resolve conflicts after the rad init refactor on main that moved shared prompt and display logic into pkg/cli/cmd/radinit/common. - application.go/application_test.go: keep PR's deletion (rad init no longer prompts to scaffold an application). - display.go: keep PR's BicepConfig rename. Switch to the thin wrapper introduced on main and pass the bicepconfig file through a new common.BicepConfigDisplay so the shared summary/progress views render the '🚧 Create bicepconfig.json' step. - common/display.go: add BicepConfigDisplay, BicepConfigComplete, and the bicepconfig summary/progress rendering. Make isComplete only require ApplicationComplete when scaffolding and BicepConfigComplete when bicepconfig files are present, so both rad init and rad init --preview work. - pkg/cli/setup/application.go: restore ScaffoldApplication so rad init --preview keeps building (it scaffolds app.bicep and reuses ScaffoldBicepConfig). - init_test.go: drop the application prompt mock setup and the new 'create application - initial appname is invalid' test case; switch to common.ResultConfirmed and common.ProgressModel.
Mirror the rad init change for the --preview command: - Delete preview/application.go and preview/application_test.go. - Drop applicationOptions, the Application field on initOptions, and the enterApplicationOptions call in preview/options.go. - Replace the application scaffold step in preview/init.go with the same bicepconfig scaffold + warning flow used by rad init. The Application scaffold step is gone; a bicepconfig.json is always created and the user is warned if one already existed. - Update preview/display.go to populate common.BicepConfigDisplay so the shared summary/progress views render the bicepconfig step. - Strip setScaffoldApplicationPrompt* and setApplicationNamePrompt calls from preview/init_test.go, drop the 'create application - initial appname is invalid' test case and the helper functions, remove the Application field from the Test_Run options, and t.Chdir to a temp dir so bicepconfig scaffolding does not affect the source tree. - Remove pkg/cli/setup.ScaffoldApplication; nothing references it now.
Neither rad init nor rad init --preview scaffold an application any more, so the helpers and display fields that supported that flow are unused. - Delete pkg/cli/cmd/radinit/common/application.go and its test file (EnterApplicationOptions and the Confirm/Enter prompt constants). - Drop ApplicationDisplay, DisplayOptions.Application, and ProgressMsg.ApplicationComplete from common/display.go, along with the SummaryApplication* constants and the application branches in the summary/progress views and isComplete. - Update the rad init Run doc comment to say it scaffolds a bicepconfig.json (not an application).
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Description
Why
The
rad initcommand currently asks "Setup application in the current directory?" — a prompt that is vague and confusing. Answering "yes" creates both abicepconfig.json(required for Bicep authoring with Radius) and a sampleapp.bicep. Answering "no" skipsbicepconfig.jsonentirely, leaving users without the required Bicep configuration and causing downstream authoring failures. This friction has been a recurring source of confusion during onboarding.What changed
rad initno longer asks users whether to scaffold an application.bicepconfig.jsonis now always created — Since this file is required for Radius Bicep authoring, it is scaffolded unconditionally. If abicepconfig.jsonalready exists, it is preserved and a warning is emitted so users know to verify it contains the necessary Radius extensions.app.bicepis no longer generated — The sample application file added unnecessary clutter and is no longer created.output.LogInfowrites from Helm were corrupting the Bubble Tea in-place progress rendering. ALoggerfield was added toClusterOptionsso callers can redirect or suppress log output.summaryApplicationHeadingIcon→summaryBicepConfigHeadingIcon,progressMsg.ApplicationComplete→BicepConfigCompleteto reflect that the step now only createsbicepconfig.json.application.go— Removed theenterApplicationOptions/enterApplicationNameflow andapplicationOptionsstruct, along with their tests.Test_Run_WarnsWhenBicepConfigAlreadyExists,Test_Run_InstallRadiusError,Test_ClusterOptions_logf_*, and additionalScaffoldBicepConfigerror-path tests.How this improves usability
Users running
rad initwill always end up with the correct Bicep configuration without needing to understand what the "setup application" prompt meant. This removes a common pitfall for new users and simplifies the init flow.Type of change
Fixes: #11771
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: