-
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
Add capabilities to resource type API #8182
Conversation
/cc @lakshmimsft |
@@ -4,34 +4,34 @@ types: | |||
apiVersions: | |||
"2025-01-01-preview": | |||
schema: {} | |||
capabilities: [] | |||
capabilities: [] |
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.
Note: we decided to move this to the resource type rather than the API version.
There are edge cases in how a consumer should behave for a capability that was added to a resource type, and is missing support from previous API versions. These edge cases are present regardless of where we configure the capability, so we went with the simplest design.
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.
A lot of the changes in this PR are updates to existing configuration files or tests.
extenders: | ||
apiVersions: | ||
"2025-01-01-preview": | ||
schema: {} | ||
capabilities: ["Recipes"] | ||
capabilities: ["SupportsRecipes"] |
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.
Note: We wanted capabilities to use a Verb+Noun naming style so they are more readable.
@@ -140,6 +140,7 @@ func (r *Runner) Run(ctx context.Context) error { | |||
r.Output.LogInfo("Creating resource type %s/%s", r.ResourceProvider.Name, resourceTypeName) | |||
_, err := client.CreateOrUpdateResourceType(ctx, "local", r.ResourceProvider.Name, resourceTypeName, &v20231001preview.ResourceTypeResource{ | |||
Properties: &v20231001preview.ResourceTypeProperties{ | |||
Capabilities: to.SliceOfPtrs(resourceType.Capabilities...), |
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.
Prior to this change, it was possible to include capabilities in a manifest, but they were unused.
return nil | ||
} | ||
|
||
return v1.NewClientErrInvalidRequest(fmt.Sprintf("capability %q is not recognized. Supported capabilities: %s", *input, datamodel.CapabilitySupportsRecipes)) |
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 validation will be expanded over time, and potentially made more flexible. For right now we're just validating that one capability we support.
|
||
const ( | ||
// CapabilitySupportsRecipes is a capability that indicates the resource type supports recipes. | ||
CapabilitySupportsRecipes = "SupportsRecipes" |
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 next pull-request for UDT will read this capability and run the recipe engine if needed.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8182 +/- ##
==========================================
- Coverage 60.15% 60.15% -0.01%
==========================================
Files 587 587
Lines 38923 38943 +20
==========================================
+ Hits 23415 23426 +11
- Misses 13781 13787 +6
- Partials 1727 1730 +3 ☔ View full report in Codecov by Sentry. |
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... |
@@ -40,7 +43,4 @@ type ResourceTypeAPIVersion struct { | |||
// TODO: this allows anything right now, and will be ignored. We'll improve this in | |||
// a future pull-request. |
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.
👍
DefaultAPIVersion: dm.Properties.DefaultAPIVersion, | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func validateCapability(input *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.
we need a unit test for new function.
due to rebase, this file will need update: /pkg/ucp/integrationtests/resourceproviders/testdata/manifests/resourceprovider-valid1.yaml and |
This change adds the 'capabilities' concept to the resource type API. - Capabilities enable resource types to indicate the schema and behaviors they support. - Capabilities enable clients like the `rad` CLI to understand the behaviors of resource types dynamically. For example, we're adding the `SupportsRecipes` capability. - All resource types that support recipes should declare this capability. This is how a UDT will opt-in to recipe functionality during provisioning. - The `rad` CLI functionality for `rad recipe register` can introspect the resource type to validate recipe support, rather than hardcoding which types have the support and which don't. ---- Description of the changes: - The manifests previously supported capabilities as part of the API version, we're moving this to the resource type for a simplification. - The manifest entry for capabilities wasn't sent to the server. Now it is. - Updated API, converters, and UCP functionality. Signed-off-by: Ryan Nowak <nowakra@gmail.com>
@lakshmimsft - updated, can you re-review? |
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... |
Description
This change adds the 'capabilities' concept to the resource type API.
rad
CLI to understand the behaviors of resource types dynamically.For example, we're adding the
SupportsRecipes
capability.rad
CLI functionality forrad recipe register
can introspect the resource type to validate recipe support, rather than hardcoding which types have the support and which don't.Description of the changes:
Type of change
Part of: #6688
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: