-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove hardcoded list of resource types from cli. #8286
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8286 +/- ##
==========================================
- Coverage 59.84% 59.80% -0.04%
==========================================
Files 590 590
Lines 39513 39535 +22
==========================================
- Hits 23645 23643 -2
- Misses 14110 14126 +16
- Partials 1758 1766 +8 ☔ View full report in Codecov by Sentry. |
4ec7b77
to
3c5e6e0
Compare
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
303cf36
to
d18246c
Compare
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
|
||
resourceTypeNames := []string{} | ||
for _, summary := range resourceProviderSummaries { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can be removed
@@ -74,6 +74,14 @@ var ( | |||
} | |||
) | |||
|
|||
var ( | |||
ExcludeResourceTypesList = []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExcludeResourceTypesList = []string{ | |
ExcludedResourceTypesList = []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can have an ExcludedResourceProvidersList for future. This would enable us to block a resource provider from being used all together instead of doing it by adding all of its resource types here.
@@ -804,6 +773,76 @@ func (amc *UCPApplicationsManagementClient) GetResourceProviderSummary(ctx conte | |||
return response.ResourceProviderSummary, nil | |||
} | |||
|
|||
// ListAllResourceTypes lists all resource types in all resource providers in the configured scope. | |||
func (amc *UCPApplicationsManagementClient) ListAllResourceTypesNames(ctx context.Context, planeName string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we need a function that lists all resource types by provider?
} | ||
|
||
resourceTypeNames := []string{} | ||
for _, summary := range resourceProviderSummaries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming summary to resourceProvider would make things clearer in the code below.
return nil, err | ||
} | ||
|
||
ResourceTypesList, err := amc.ListAllResourceTypesNames(ctx, "local") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResourceTypesList, err := amc.ListAllResourceTypesNames(ctx, "local") | |
resourceTypesList, err := amc.ListAllResourceTypesNames(ctx, "local") |
variables should start with lower case letters
mockResourceClient := NewMockgenericResourceClient(gomock.NewController(t)) | ||
mockResourceProviderClient := NewMockresourceProviderClient(gomock.NewController(t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the casing for the functions off?
mockResourceClient := NewMockgenericResourceClient(gomock.NewController(t)) | |
mockResourceProviderClient := NewMockresourceProviderClient(gomock.NewController(t)) | |
mockResourceClient := NewMockGenericResourceClient(gomock.NewController(t)) | |
mockResourceProviderClient := NewMockResourceProviderClient(gomock.NewController(t)) |
mockResourceProviderClient.EXPECT().NewListProviderSummariesPager("local", gomock.Any()).Return(pager(resourceProviderSummaryPages)) | ||
mockResourceClient.EXPECT(). | ||
NewListByRootScopePager(gomock.Any()). | ||
Return(pager(listPages)).AnyTimes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the expected values instead of gomock.Any()
s?
} else if len(foundTypes) > 1 { | ||
return "", fmt.Errorf("multiple resource types match '%s'. Please specify the full resource type and try again:\n\n%s\n", | ||
resourceTypeName, strings.Join(foundTypes, "\n")) | ||
if !strings.Contains(resourceTypeName, "/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only check for the resource type?
rad resource create 'Applications.Core/containers' mycontainer -f /path/to/input.json`, | ||
rad resource create 'applications.core/containers' mycontainer -f /path/to/input.json`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we only support the lower case now? Why not both?
@@ -45,18 +47,18 @@ func NewCommand(factory framework.Factory) (*cobra.Command, framework.Runner) { | |||
Short: "Lists resources", | |||
Long: "List all resources of specified type", | |||
Example: ` | |||
sample list of resourceType: containers, gateways, pubSubBrokers, extenders, mongoDatabases, rabbitMQMessageQueues, redisCaches, sqlDatabases, stateStores, secretStores | |||
sample list of resourceType: applications.core/containers, applications.core/gateways, applications.dapr/daprPubSubBrokers, applications.core/extenders, applications.datastores/mongoDatabases, applications.messaging/rabbitMQMessageQueues, applications.datastores/redisCaches, applications.datastores/sqlDatabases, applications.dapr/daprStateStores, applications.dapr/daprSecretStores |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are resource providers all lower case but some resource types camel case?
Description
Since we now register resource provider manifests at startup and are in process of enabling UDT end to end, we should not use static resource type lists.
This PR removes static resource type lists in cli code.
Type of change
https://dev.azure.com/azure-octo/Incubations/_sprints/taskboard/Radius%20Team/Incubations/Radius/Sprint%2061?workitem=13649
https://dev.azure.com/azure-octo/Incubations/_sprints/taskboard/Radius%20Team/Incubations/Radius/Sprint%2061?workitem=13652
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: