-
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.
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
} 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?
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.
No, the types are stored normalized. I was just trying keep it consistent in docs. we soecify only the type name for creation so I have updated this text.
nithya@MacBook-Pro radius % rad resource-provider show applications.core
RESOURCE TYPE STATE
Applications.Core
@@ -44,7 +44,7 @@ func Test_Validate(t *testing.T) { | |||
testcases := []radcli.ValidateInput{ | |||
{ | |||
Name: "Valid Delete Command", |
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 add a test for delete with unsupported resource type?
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.
looks like all the rad resource commands will need a test for resource type and provider's existence before processing the request. Is it OK to create a ticket to address this as another task?
parts := strings.Split(r.ResourceType, "/") | ||
if len(parts) != 2 { | ||
return clierrors.Message("Invalid resource type %q. Expected format: '<provider>/<type>'", r.ResourceType) | ||
} | ||
resourceProviderNamespace := parts[0] | ||
resourceTypeSuffix := parts[1] | ||
_, err = common.GetResourceTypeDetails(ctx, resourceProviderNamespace, resourceTypeSuffix, client) | ||
if err != nil { | ||
return err | ||
} |
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 this needed in addtion to RequireResourceType?
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.
the user enters a fully qualified name, liek applications.core/container, which is checked for correctness. But a lot of api calls need one of the provider or type. So we are having to split it again. Mostly this call is used in rad resource commands and I would like to talk a bit more about it, to discuss introducing another function RequireFullyQualifiedResourceType which can return in desired format.
Name: "List Command with ambiguous args", | ||
Input: []string{"secretStores"}, | ||
ExpectedValid: false, | ||
ConfigHolder: framework.ConfigHolder{ | ||
ConfigFilePath: "", | ||
Config: configWithWorkspace, | ||
}, |
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.
What did we change to remove this scenario?
if strings.EqualFold(*resources[0].Type, "Applications.Datastores/mongoDatabases") { | ||
require.Equal(t, mongoDBName, *resources[0].Name) | ||
require.Equal(t, "Applications.Core/containers", *resources[1].Type) | ||
require.Equal(t, containerName, *resources[1].Name) | ||
} else { | ||
require.Equal(t, "Applications.Core/containers", *resources[0].Type) | ||
require.Equal(t, containerName, *resources[0].Name) | ||
require.Equal(t, mongoDBName, *resources[1].Name) | ||
require.Equal(t, "Applications.Datastores/mongoDatabases", *resources[1].Type) | ||
} |
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.
This is interesting.. how was the order guaranteed before?
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 am not sure .. but when I debuged I noticed only the order was different when it failed.
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
Part of #6688
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: