Skip to content

Conversation

@vishwahiremat
Copy link
Contributor

@vishwahiremat vishwahiremat commented Dec 10, 2025

Description

Added Providers details for env show command with --preview flag.

  • Updated the rad env show --preview command to add provider details.
  • Updated the tests.

Updated the Aws provider properties

  • Removed the scope property and made it consistent with Azure provider by adding properties accoutId and region separately
  • Added typespec changes
  • refactored to reflect these changes in conversion/tests and cli.

How to Test:

  • checkout this PR
  • run the control plane locally
  • run sudo make install to get the latest cli changes
image

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).

#9832

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

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 44.44444% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.42%. Comparing base (a45fc2f) to head (2f5d1f2).

Files with missing lines Patch % Lines
pkg/cli/test_client_factory/radius_core.go 0.00% 13 Missing ⚠️
pkg/cli/objectformats/objectformats.go 0.00% 10 Missing ⚠️
...erp/api/v20250801preview/environment_conversion.go 0.00% 4 Missing ⚠️
pkg/cli/cmd/env/show/preview/show.go 90.47% 1 Missing and 1 partial ⚠️
pkg/cli/cmd/env/update/preview/update.go 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10925      +/-   ##
==========================================
- Coverage   50.43%   50.42%   -0.02%     
==========================================
  Files         672      672              
  Lines       42057    42104      +47     
==========================================
+ Hits        21213    21231      +18     
- Misses      18788    18815      +27     
- Partials     2056     2058       +2     

☔ 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.

@radius-functional-tests
Copy link

radius-functional-tests bot commented Dec 10, 2025

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository vishwahiremat/radius
Commit ref 2f5d1f2
Unique ID func2108fdc509
Image tag pr-func2108fdc509
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func2108fdc509
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func2108fdc509
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func2108fdc509
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func2108fdc509
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func2108fdc509
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
❌ ucp-cloud functional test failed. Please check the logs for more details
❌ corerp-cloud functional test cancelled. Please check the logs for more details
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded

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

This pull request updates the AWS provider configuration schema to use separate accountId and region fields instead of a single scope field, making it consistent with the Azure provider design. It also adds provider details display to the rad env show --preview command output.

Key Changes

  • Refactored AWS provider from single scope property to separate accountId and region properties for better consistency with Azure provider
  • Added provider information display to rad env show --preview command
  • Updated TypeSpec definitions, OpenAPI specifications, datamodel structures, and all related conversion logic

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
typespec/Radius.Core/environments.tsp Updated ProvidersAws model to use separate accountId and region fields instead of scope
swagger/specification/radius/resource-manager/Radius.Core/preview/2025-08-01-preview/openapi.json Updated OpenAPI spec for ProvidersAws with new field structure and required fields
pkg/corerp/datamodel/environment_v20250801preview.go Updated datamodel to reflect new AccountID and Region fields with JSON tags
pkg/corerp/api/v20250801preview/zz_generated_models.go Updated generated API models for ProvidersAws structure
pkg/corerp/api/v20250801preview/zz_generated_models_serde.go Updated JSON marshaling/unmarshaling for new AWS provider fields
pkg/corerp/api/v20250801preview/environment_conversion.go Updated conversion logic between API and datamodel for AWS provider
pkg/recipes/configloader/environment.go Updated to construct AWS scope from separate accountId and region fields
pkg/recipes/configloader/environment_test.go Updated test data to use new AWS provider structure
pkg/cli/objectformats/objectformats.go Added new table format function for displaying provider information
pkg/cli/cmd/env/show/preview/show.go Added provider details display logic with formatting for Azure, AWS, and Kubernetes providers
pkg/cli/cmd/env/show/preview/show_test.go Added test coverage for provider display functionality
pkg/cli/cmd/env/update/preview/update.go Updated validation and update logic to handle separate AWS accountId and region fields; removed unused fmt import
pkg/cli/cmd/env/update/preview/update_test.go Updated test data to use new AWS provider field structure
pkg/cli/test_client_factory/radius_core.go Added provider configuration to test environment resource
hack/bicep-types-radius/generated/radius/radius.core/2025-08-01-preview/types.json Updated Bicep types definition for AWS provider fields

// Provider is the type of the provider (e.g., "azure", "aws", "kubernetes").
Provider string
// Properties contains the provider details in a comma-separated key-value format.
// e.g., "subscriptionId: 'sub-id', resourceGroupName: 'rg-name'" for azure provider."
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

There is an extra period at the end of the example comment that should be removed for consistency with other comment lines.

Suggested change
// e.g., "subscriptionId: 'sub-id', resourceGroupName: 'rg-name'" for azure provider."
// e.g., "subscriptionId: 'sub-id', resourceGroupName: 'rg-name'" for azure provider

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +172
envProviders := []EnvProviders{}
if resp.EnvironmentResource.Properties.Providers != nil {
if resp.EnvironmentResource.Properties.Providers.Azure != nil {
azureProvider := EnvProviders{
Provider: "azure",
}
azureProvider.Properties = "subscriptionId: '" + *resp.EnvironmentResource.Properties.Providers.Azure.SubscriptionID + "', resourceGroupName: '" + *resp.EnvironmentResource.Properties.Providers.Azure.ResourceGroupName + "'"
envProviders = append(envProviders, azureProvider)
}

if resp.EnvironmentResource.Properties.Providers.Aws != nil {
awsProvider := EnvProviders{
Provider: "aws",
}
awsProvider.Properties = "accountId: '" + *resp.EnvironmentResource.Properties.Providers.Aws.AccountID + "', region: '" + *resp.EnvironmentResource.Properties.Providers.Aws.Region + "'"
envProviders = append(envProviders, awsProvider)
}
if resp.EnvironmentResource.Properties.Providers.Kubernetes != nil {
k8sProvider := EnvProviders{
Provider: "kubernetes",
}
k8sProvider.Properties = "namespace: '" + *resp.EnvironmentResource.Properties.Providers.Kubernetes.Namespace + "'"
envProviders = append(envProviders, k8sProvider)
}
}
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The provider formatting logic is repetitive and could be refactored into a helper function to reduce code duplication. Consider extracting a function that takes provider type, field names, and values to construct the Properties string. This would make the code more maintainable and reduce the risk of inconsistent formatting across providers.

Copilot uses AI. Check for mistakes.
azureProvider := EnvProviders{
Provider: "azure",
}
azureProvider.Properties = "subscriptionId: '" + *resp.EnvironmentResource.Properties.Providers.Azure.SubscriptionID + "', resourceGroupName: '" + *resp.EnvironmentResource.Properties.Providers.Azure.ResourceGroupName + "'"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Potential nil pointer dereference when accessing provider properties. If any of the pointer fields (SubscriptionID, ResourceGroupName, AccountID, Region, or Namespace) are nil, dereferencing them will cause a panic. Add nil checks before dereferencing these pointers or use helper functions to safely access pointer values.

Copilot uses AI. Check for mistakes.
awsProvider := EnvProviders{
Provider: "aws",
}
awsProvider.Properties = "accountId: '" + *resp.EnvironmentResource.Properties.Providers.Aws.AccountID + "', region: '" + *resp.EnvironmentResource.Properties.Providers.Aws.Region + "'"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Potential nil pointer dereference when accessing AWS provider AccountID and Region fields. If either field is nil, dereferencing will cause a panic. Add nil checks before dereferencing these pointers or use helper functions to safely access pointer values.

Suggested change
awsProvider.Properties = "accountId: '" + *resp.EnvironmentResource.Properties.Providers.Aws.AccountID + "', region: '" + *resp.EnvironmentResource.Properties.Providers.Aws.Region + "'"
accountID := ""
if resp.EnvironmentResource.Properties.Providers.Aws.AccountID != nil {
accountID = *resp.EnvironmentResource.Properties.Providers.Aws.AccountID
}
region := ""
if resp.EnvironmentResource.Properties.Providers.Aws.Region != nil {
region = *resp.EnvironmentResource.Properties.Providers.Aws.Region
}
awsProvider.Properties = "accountId: '" + accountID + "', region: '" + region + "'"

Copilot uses AI. Check for mistakes.
k8sProvider := EnvProviders{
Provider: "kubernetes",
}
k8sProvider.Properties = "namespace: '" + *resp.EnvironmentResource.Properties.Providers.Kubernetes.Namespace + "'"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Potential nil pointer dereference when accessing Kubernetes Namespace field. If the Namespace field is nil, dereferencing will cause a panic. Add nil checks before dereferencing this pointer or use helper functions to safely access pointer values.

Suggested change
k8sProvider.Properties = "namespace: '" + *resp.EnvironmentResource.Properties.Providers.Kubernetes.Namespace + "'"
namespace := ""
if resp.EnvironmentResource.Properties.Providers.Kubernetes.Namespace != nil {
namespace = *resp.EnvironmentResource.Properties.Providers.Kubernetes.Namespace
}
k8sProvider.Properties = "namespace: '" + namespace + "'"

Copilot uses AI. Check for mistakes.
azureProvider := EnvProviders{
Provider: "azure",
}
azureProvider.Properties = "subscriptionId: '" + *resp.EnvironmentResource.Properties.Providers.Azure.SubscriptionID + "', resourceGroupName: '" + *resp.EnvironmentResource.Properties.Providers.Azure.ResourceGroupName + "'"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Using direct string concatenation with the + operator. For better performance and idiomatic Go code, use strings.Builder or fmt.Sprintf when building strings from multiple parts. This is particularly important since this code constructs display strings for potentially multiple providers.

Copilot generated this review using guidance from repository custom instructions.
awsProvider := EnvProviders{
Provider: "aws",
}
awsProvider.Properties = "accountId: '" + *resp.EnvironmentResource.Properties.Providers.Aws.AccountID + "', region: '" + *resp.EnvironmentResource.Properties.Providers.Aws.Region + "'"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Using direct string concatenation with the + operator. For better performance and idiomatic Go code, use strings.Builder or fmt.Sprintf when building strings from multiple parts. This is particularly important since this code constructs display strings for potentially multiple providers.

Copilot generated this review using guidance from repository custom instructions.
if envDatamodel.Properties.Providers.AWS != nil {
config.Providers.AWS = datamodel.ProvidersAWS{
Scope: envDatamodel.Properties.Providers.AWS.Scope,
Scope: "/planes/aws/aws/accounts/" + envDatamodel.Properties.Providers.AWS.AccountID + "/regions/" + envDatamodel.Properties.Providers.AWS.Region,
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Using direct string concatenation with the + operator to construct the AWS scope path. For better performance and idiomatic Go code, use fmt.Sprintf or strings.Builder when building strings from multiple parts. Consider using fmt.Sprintf with a format string like "/planes/aws/aws/accounts/%s/regions/%s" for clarity.

Copilot generated this review using guidance from repository custom instructions.
k8sProvider := EnvProviders{
Provider: "kubernetes",
}
k8sProvider.Properties = "namespace: '" + *resp.EnvironmentResource.Properties.Providers.Kubernetes.Namespace + "'"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Using direct string concatenation with the + operator. For better performance and idiomatic Go code, use strings.Builder or fmt.Sprintf when building strings from multiple parts. This is particularly important since this code constructs display strings for potentially multiple providers.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +121 to +133
Providers: &corerpv20250801.Providers{
Azure: &corerpv20250801.ProvidersAzure{
SubscriptionID: to.Ptr("test-subscription-id"),
ResourceGroupName: to.Ptr("test-resource-group"),
},
Aws: &corerpv20250801.ProvidersAws{
AccountID: to.Ptr("test-account-id"),
Region: to.Ptr("test-region"),
},
Kubernetes: &corerpv20250801.ProvidersKubernetes{
Namespace: to.Ptr("test-namespace"),
},
},
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Test coverage is missing for scenarios where provider fields could be nil. The new code in show.go dereferences pointer fields without nil checks (lines 154, 162, 169), which could cause panics. Add test cases covering environments with partially configured providers or nil pointer fields to ensure the code handles these edge cases gracefully.

Copilot uses AI. Check for mistakes.
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.

1 participant