Skip to content

Commit

Permalink
Redesign plane resource types
Browse files Browse the repository at this point in the history
This change splits the plane resource type into multiple types for maintainability as reviewed in radius-project/design-notes#42. See the design document for the motivation and dicussion of the specific design details. In summary, previously we had one resource type for all planes, and now we have a few separate ones.

This is a technically a breaking change but the impact on users is very low because it's mainly UCP itself that interacts with the planes.

The majority of the code changes are due to:

    Simplifying the resource group client API
    Updating and adding examples

Signed-off-by: Ryan Nowak <nowakra@gmail.com>
  • Loading branch information
gpltaylor authored and rynowak committed May 6, 2024
1 parent 4d7ee44 commit e1724f6
Show file tree
Hide file tree
Showing 160 changed files with 6,216 additions and 2,041 deletions.
79 changes: 34 additions & 45 deletions deploy/Chart/crds/radius/radapp.io_recipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.9.1
creationTimestamp: null
name: recipes.radapp.io
spec:
group: radapp.io
Expand Down Expand Up @@ -36,34 +37,29 @@ spec:
description: Recipe is the Schema for the recipes API
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RecipeSpec defines the desired state of Recipe
properties:
application:
description: |-
Application is the name of the Radius application to use. If unset the namespace of the
Recipe will be used as the application name.
description: Application is the name of the Radius application to
use. If unset the namespace of the Recipe will be used as the application
name.
type: string
environment:
description: |-
Environment is the name of the Radius environment to use. If unset the value 'default' will be
used as the environment name.
description: Environment is the name of the Radius environment to
use. If unset the value 'default' will be used as the environment
name.
type: string
secretName:
description: SecretName is the name of a Kubernetes secret to create
Expand All @@ -83,9 +79,9 @@ spec:
description: Environment is the resource ID of the environment.
type: string
observedGeneration:
description: |-
ObservedGeneration is the most recent generation observed for this Recipe. It corresponds to the
Recipe's generation, which is updated on mutation by the API Server.
description: ObservedGeneration is the most recent generation observed
for this Recipe. It corresponds to the Recipe's generation, which
is updated on mutation by the API Server.
format: int64
type: integer
operation:
Expand Down Expand Up @@ -118,40 +114,33 @@ spec:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
TODO: this design is not final and this field is subject to change in the future.
description: 'If referring to a piece of an object instead of
an entire object, this string should contain a valid JSON/Go
field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within
a pod, this would take on a value like: "spec.containers{name}"
(where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]"
(container with index 2 in this pod). This syntax is chosen
only to have some well-defined way of referencing a part of
an object. TODO: this design is not final and this field is
subject to change in the future.'
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
description: 'Specific resourceVersion to which this reference
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
x-kubernetes-map-type: atomic
Expand Down
20 changes: 8 additions & 12 deletions deploy/Chart/crds/ucpd/ucp.dev_queuemessages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.9.1
creationTimestamp: null
name: queuemessages.ucp.dev
spec:
group: ucp.dev
Expand All @@ -20,19 +21,14 @@ spec:
description: QueueMessage is the Schema for QueueMessage API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Expand Down
20 changes: 8 additions & 12 deletions deploy/Chart/crds/ucpd/ucp.dev_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.9.1
creationTimestamp: null
name: resources.ucp.dev
spec:
group: ucp.dev
Expand All @@ -20,11 +21,9 @@ spec:
description: Resource is the Schema for the resources API
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
entries:
items:
Expand All @@ -48,12 +47,9 @@ spec:
type: object
type: array
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ucp:
| Key | Description | Example |
|-----|-------------|---------|
| id | The ID of the UCP plane | `/planes/radius/local` |
| type | The type of UCP plane | `System.Planes/radius` |
| type | The type of UCP plane | `System.Radius/planes` |
| name | The name of the UCP plane | `ucp` |
| properties | The properties specified on the plane | [**See below**](#properties) |

Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ type ApplicationsManagementClient interface {
ListEnvironmentsAll(ctx context.Context) ([]corerp.EnvironmentResource, error)
GetEnvDetails(ctx context.Context, envName string) (corerp.EnvironmentResource, error)
DeleteEnv(ctx context.Context, envName string) (bool, error)
CreateUCPGroup(ctx context.Context, planeType string, planeName string, resourceGroupName string, resourceGroup ucp_v20231001preview.ResourceGroupResource) error
DeleteUCPGroup(ctx context.Context, planeType string, planeName string, resourceGroupName string) (bool, error)
ShowUCPGroup(ctx context.Context, planeType string, planeName string, resourceGroupName string) (ucp_v20231001preview.ResourceGroupResource, error)
ListUCPGroup(ctx context.Context, planeType string, planeName string) ([]ucp_v20231001preview.ResourceGroupResource, error)
CreateUCPGroup(ctx context.Context, planeName string, resourceGroupName string, resourceGroup ucp_v20231001preview.ResourceGroupResource) error
DeleteUCPGroup(ctx context.Context, planeName string, resourceGroupName string) (bool, error)
ShowUCPGroup(ctx context.Context, planeName string, resourceGroupName string) (ucp_v20231001preview.ResourceGroupResource, error)
ListUCPGroup(ctx context.Context, planeName string) ([]ucp_v20231001preview.ResourceGroupResource, error)

// ShowRecipe shows recipe details including list of all parameters for a given recipe registered to an environment
ShowRecipe(ctx context.Context, environmentName string, recipe corerp.RecipeGetMetadata) (corerp.RecipeGetMetadataResponse, error)
Expand Down
18 changes: 9 additions & 9 deletions pkg/cli/clients/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,14 @@ func (amc *UCPApplicationsManagementClient) DeleteEnv(ctx context.Context, envNa

// CreateUCPGroup creates a new resource group in the specified plane type and plane name using the provided resource
// group resource and returns an error if one occurs.
func (amc *UCPApplicationsManagementClient) CreateUCPGroup(ctx context.Context, planeType string, planeName string, resourceGroupName string, resourceGroup ucpv20231001.ResourceGroupResource) error {
func (amc *UCPApplicationsManagementClient) CreateUCPGroup(ctx context.Context, planeName string, resourceGroupName string, resourceGroup ucpv20231001.ResourceGroupResource) error {
var resourceGroupOptions *ucpv20231001.ResourceGroupsClientCreateOrUpdateOptions
resourcegroupClient, err := ucpv20231001.NewResourceGroupsClient(&aztoken.AnonymousCredential{}, amc.ClientOptions)
if err != nil {
return err
}

_, err = resourcegroupClient.CreateOrUpdate(ctx, planeType, planeName, resourceGroupName, resourceGroup, resourceGroupOptions)
_, err = resourcegroupClient.CreateOrUpdate(ctx, planeName, resourceGroupName, resourceGroup, resourceGroupOptions)
if err != nil {
return err
}
Expand All @@ -568,7 +568,7 @@ func (amc *UCPApplicationsManagementClient) CreateUCPGroup(ctx context.Context,

// DeleteUCPGroup attempts to delete a UCP resource group using the provided plane type, plane name and resource group
// name, and returns a boolean indicating success or failure and an error if one occurs.
func (amc *UCPApplicationsManagementClient) DeleteUCPGroup(ctx context.Context, planeType string, planeName string, resourceGroupName string) (bool, error) {
func (amc *UCPApplicationsManagementClient) DeleteUCPGroup(ctx context.Context, planeName string, resourceGroupName string) (bool, error) {
var resourceGroupOptions *ucpv20231001.ResourceGroupsClientDeleteOptions
resourcegroupClient, err := ucpv20231001.NewResourceGroupsClient(&aztoken.AnonymousCredential{}, amc.ClientOptions)

Expand All @@ -578,7 +578,7 @@ func (amc *UCPApplicationsManagementClient) DeleteUCPGroup(ctx context.Context,
return false, err
}

_, err = resourcegroupClient.Delete(ctxWithResp, planeType, planeName, resourceGroupName, resourceGroupOptions)
_, err = resourcegroupClient.Delete(ctxWithResp, planeName, resourceGroupName, resourceGroupOptions)
if err != nil {
return false, err
}
Expand All @@ -587,16 +587,16 @@ func (amc *UCPApplicationsManagementClient) DeleteUCPGroup(ctx context.Context,

}

// ShowUCPGroup is a function that retrieves a resource group from the Azure Resource Manager using the given plane type,
// ShowUCPGroup is a function that retrieves a resource group from the UCP API using the given plane type,
// plane name and resource group name, and returns the resource group resource or an error if one occurs.
func (amc *UCPApplicationsManagementClient) ShowUCPGroup(ctx context.Context, planeType string, planeName string, resourceGroupName string) (ucpv20231001.ResourceGroupResource, error) {
func (amc *UCPApplicationsManagementClient) ShowUCPGroup(ctx context.Context, planeName string, resourceGroupName string) (ucpv20231001.ResourceGroupResource, error) {
var resourceGroupOptions *ucpv20231001.ResourceGroupsClientGetOptions
resourcegroupClient, err := ucpv20231001.NewResourceGroupsClient(&aztoken.AnonymousCredential{}, amc.ClientOptions)
if err != nil {
return ucpv20231001.ResourceGroupResource{}, err
}

resp, err := resourcegroupClient.Get(ctx, planeType, planeName, resourceGroupName, resourceGroupOptions)
resp, err := resourcegroupClient.Get(ctx, planeName, resourceGroupName, resourceGroupOptions)
if err != nil {
return ucpv20231001.ResourceGroupResource{}, err
}
Expand All @@ -606,15 +606,15 @@ func (amc *UCPApplicationsManagementClient) ShowUCPGroup(ctx context.Context, pl

// ListUCPGroup is a function that retrieves a list of resource groups from the UCP API and returns them as a slice of
// ResourceGroupResource objects. It may return an error if there is an issue with the API request.
func (amc *UCPApplicationsManagementClient) ListUCPGroup(ctx context.Context, planeType string, planeName string) ([]ucpv20231001.ResourceGroupResource, error) {
func (amc *UCPApplicationsManagementClient) ListUCPGroup(ctx context.Context, planeName string) ([]ucpv20231001.ResourceGroupResource, error) {
var resourceGroupOptions *ucpv20231001.ResourceGroupsClientListOptions
resourceGroupResources := []ucpv20231001.ResourceGroupResource{}
resourcegroupClient, err := ucpv20231001.NewResourceGroupsClient(&aztoken.AnonymousCredential{}, amc.ClientOptions)
if err != nil {
return resourceGroupResources, err
}

pager := resourcegroupClient.NewListPager(planeType, planeName, resourceGroupOptions)
pager := resourcegroupClient.NewListPager(planeName, resourceGroupOptions)

for pager.More() {
resp, err := pager.NextPage(ctx)
Expand Down
Loading

0 comments on commit e1724f6

Please sign in to comment.