Skip to content

Update radius to setup default recipepack during rad init and env operations.#11294

Open
nithyatsu wants to merge 17 commits intoradius-project:mainfrom
nithyatsu:setupdefaultpack
Open

Update radius to setup default recipepack during rad init and env operations.#11294
nithyatsu wants to merge 17 commits intoradius-project:mainfrom
nithyatsu:setupdefaultpack

Conversation

@nithyatsu
Copy link
Contributor

@nithyatsu nithyatsu commented Feb 24, 2026

Description

rad init

  • uses Radius.Core API
  • creates default pack in default and injects it into default environment

rad env create --preview

  • adds default recipe pack when creating a new Radius.Core environment

rad deploy

  • before deploying, scans the compiled ARM template for all Radius.Core/environments.
    For each environment found, inspects existing recipe packs, if none, adds default pack.

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).
  • This pull request adds or changes features of Radius and has an approved issue (issue link required).
  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Fixes: #11091

radius-project/resource-types-contrib#100 and this PR must be merged together.

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.
    • Yes
    • Not applicable

Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>

rad init implementation

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

name default pack

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

add tests

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

rad init cahnges

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

renames

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

create upadtes

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

update

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

deploy changes

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

refactor + comments

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

deploy fix

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

fix

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

remove dev recipe test

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

wip

Signed-off-by: nithyatsu <nithyasu@microsoft.com>

ci: retrigger

ci: retrigger

ci: retrigger
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
Copy link
Contributor

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

Updates the Radius CLI to ensure a default Radius.Core recipe pack is created (in the fixed default scope) and attached to environments during rad init, rad env create --preview, and rad deploy, aligning environment setup and deployments with the newer Radius.Core API surface.

Changes:

  • Introduce a pkg/cli/recipepack package to define/create the default Kubernetes core recipe pack and IDs.
  • Update rad init and rad env create --preview to create the default recipe pack and attach it to newly created Radius.Core environments.
  • Update rad deploy to scan compiled templates for Radius.Core environments and inject the default recipe pack when none are specified, with expanded fake servers/tests.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/functional-portable/cli/noncloud/testdata/corerp-recipe-pack-test.bicep Adjusts recipe pack test template contents.
test/functional-portable/cli/noncloud/cli_test.go Removes DevRecipes functional test that created env directly.
pkg/cli/test_client_factory/radius_core.go Expands Radius.Core fake servers (404-on-get env/packs, create/update handlers, type-mapping helpers).
pkg/cli/recipepack/recipepack.go Adds default recipe pack definition, IDs, and default RG scope helpers.
pkg/cli/recipepack/recipepack_test.go Adds unit tests for default recipe pack definitions and resource construction.
pkg/cli/cmd/utils.go Adds helper to build RecipePacksClients per referenced scope.
pkg/cli/cmd/utils_test.go Adds tests for the new PopulateRecipePackClients helper.
pkg/cli/cmd/radinit/options.go Switches computed workspace environment ID to Radius.Core provider namespace.
pkg/cli/cmd/radinit/options_test.go Updates expectations to match Radius.Core environment IDs.
pkg/cli/cmd/radinit/init.go Extends runner with Radius.Core client factories (workspace + default scope).
pkg/cli/cmd/radinit/init_test.go Updates init tests to use Radius.Core test client factory and reflect extra RG creation call.
pkg/cli/cmd/radinit/environment.go Creates Radius.Core environment, ensures default RG exists, creates default recipe pack, and attaches it.
pkg/cli/cmd/env/create/preview/create.go Creates Radius.Core environment and attaches default recipe pack during preview env creation.
pkg/cli/cmd/env/create/preview/create_test.go Updates preview env-create tests for default recipe pack behavior and output.
pkg/cli/cmd/deploy/deploy.go Adds deploy-time default recipe pack injection for Radius.Core environments in compiled templates.
pkg/cli/cmd/deploy/deploy_test.go Adds tests covering recipe pack injection/no-op paths and default-pack creation behavior.

Comment on lines +151 to +152
// This is the bicep reference for id, and cannot be invalid.
packID, _ := resources.Parse(packIDStr)
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Don't ignore the error from resources.Parse(packIDStr). If packIDStr is malformed (or an ARM/Bicep expression), Parse will fail and RootScope() will produce an incorrect scope (often "/"), leading to clients being created against the wrong scope. Return a clear error (or skip/handle expression IDs explicitly) when Parse fails.

Suggested change
// This is the bicep reference for id, and cannot be invalid.
packID, _ := resources.Parse(packIDStr)
// This is expected to be a valid bicep reference for id, but we still
// validate and fail fast if parsing does not succeed to avoid using
// an incorrect default scope.
packID, err := resources.Parse(packIDStr)
if err != nil {
return fmt.Errorf("failed to parse recipe pack ID %q: %w", packIDStr, err)
}

Copilot uses AI. Check for mistakes.
Comment on lines +114 to +118
defaultPack := recipepack.NewDefaultRecipePackResource()
_, err = r.DefaultScopeClientFactory.NewRecipePacksClient().CreateOrUpdate(ctx, recipepack.DefaultRecipePackResourceName, defaultPack, nil)
if err != nil {
return clierrors.MessageWithCause(err, "Failed to create default recipe pack.")
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Creating the default recipe pack via CreateOrUpdate on every init run can overwrite user modifications to an existing "default" pack in the default scope. Prefer a GET-first flow (create only on 404) or use an ETag/If-Match strategy so init doesn't clobber an existing pack unexpectedly.

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +174
defaultPack := recipepack.NewDefaultRecipePackResource()
_, err = r.DefaultScopeClientFactory.NewRecipePacksClient().CreateOrUpdate(ctx, recipepack.DefaultRecipePackResourceName, defaultPack, nil)
if err != nil {
return err
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Creating the default recipe pack with CreateOrUpdate unconditionally can overwrite an existing user-customized "default" pack in the default scope. Prefer checking for existence (GET + create on 404) before writing, consistent with the deploy path's get-or-create behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +81 to 92
envProperties := corerpv20250801.EnvironmentProperties{
Providers: providers,
}

var recipes map[string]map[string]corerp.RecipePropertiesClassification
if r.Options.Recipes.DevRecipes {
// Note: To use custom registry for recipes, users need to manually configure
// their environment after initialization or use custom recipe definitions
recipes, err = r.DevRecipeClient.GetDevRecipes(ctx)
// Initialize the Radius.Core client factory if not already set
if r.RadiusCoreClientFactory == nil {
clientFactory, err := cmd.InitializeRadiusCoreClientFactory(ctx, r.Workspace, r.Workspace.Scope)
if err != nil {
return err
return clierrors.MessageWithCause(err, "Failed to initialize Radius Core client.")
}
r.RadiusCoreClientFactory = clientFactory
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

rad init still sets/prints options.Recipes.DevRecipes (and Runner still carries DevRecipeClient), but CreateEnvironment no longer uses either to influence the created environment. Either remove the dev-recipes option/UI/fields or reintroduce equivalent behavior using the new Radius.Core recipe pack model so the option isn't a no-op.

Copilot uses AI. Check for mistakes.
Comment on lines 137 to +147
// DevRecipeClient is the interface for the dev recipe client.
DevRecipeClient DevRecipeClient

// RadiusCoreClientFactory is the client factory for Radius.Core resources.
// If nil, it will be initialized during Run.
RadiusCoreClientFactory *corerpv20250801.ClientFactory

// DefaultScopeClientFactory is the client factory scoped to the default resource group.
// Singleton recipe packs are always created/queried in the default scope.
DefaultScopeClientFactory *corerpv20250801.ClientFactory

Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Runner.DevRecipeClient appears to be unused now that environment creation no longer applies dev recipes. Consider removing this field (and related wiring) or updating the new recipe-pack-based flow to use it, to avoid dead code and misleading configuration surface.

Suggested change
// DevRecipeClient is the interface for the dev recipe client.
DevRecipeClient DevRecipeClient
// RadiusCoreClientFactory is the client factory for Radius.Core resources.
// If nil, it will be initialized during Run.
RadiusCoreClientFactory *corerpv20250801.ClientFactory
// DefaultScopeClientFactory is the client factory scoped to the default resource group.
// Singleton recipe packs are always created/queried in the default scope.
DefaultScopeClientFactory *corerpv20250801.ClientFactory
// RadiusCoreClientFactory is the client factory for Radius.Core resources.
// If nil, it will be initialized during Run.
RadiusCoreClientFactory *corerpv20250801.ClientFactory

Copilot uses AI. Check for mistakes.
Signed-off-by: nithyatsu <nithyasu@microsoft.com>
@nithyatsu nithyatsu requested a deployment to external-contributor-approval February 25, 2026 17:25 — with GitHub Actions Waiting
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 31.26685% with 255 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.79%. Comparing base (088b1fe) to head (e204475).

Files with missing lines Patch % Lines
pkg/cli/test_client_factory/radius_core.go 0.00% 182 Missing ⚠️
pkg/cli/cmd/deploy/deploy.go 53.94% 20 Missing and 15 partials ⚠️
pkg/cli/cmd/radinit/environment.go 51.51% 12 Missing and 4 partials ⚠️
pkg/cli/cmd/env/create/preview/create.go 52.17% 7 Missing and 4 partials ⚠️
pkg/cli/recipepack/recipepack.go 84.61% 6 Missing ⚠️
pkg/cli/cmd/utils.go 63.63% 4 Missing ⚠️
pkg/cli/cmd/env/update/preview/update.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11294      +/-   ##
==========================================
- Coverage   51.00%   50.79%   -0.22%     
==========================================
  Files         679      680       +1     
  Lines       43174    43508     +334     
==========================================
+ Hits        22023    22098      +75     
- Misses      19033    19267     +234     
- Partials     2118     2143      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

update rad init

2 participants