Skip to content
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

Adding in generic controllers for create and delete for linkrps #4960

Merged
merged 20 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions pkg/armrpc/frontend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
sm "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager"
"github.com/project-radius/radius/pkg/armrpc/hostoptions"
"github.com/project-radius/radius/pkg/armrpc/rest"
"github.com/project-radius/radius/pkg/linkrp/frontend/deployment"
"github.com/project-radius/radius/pkg/rp"
"github.com/project-radius/radius/pkg/ucp/dataprovider"
"github.com/project-radius/radius/pkg/ucp/store"
Expand All @@ -38,9 +37,6 @@ type Options struct {
// ResourceType is the string that represents the resource type.
ResourceType string

// GetDeploymentProcessor is the factory function to create DeploymentProcessor instance.
GetDeploymentProcessor func() deployment.DeploymentProcessor

// StatusManager
StatusManager sm.StatusManager
}
Expand Down Expand Up @@ -104,11 +100,6 @@ func (b *BaseController) ResourceType() string {
return b.options.ResourceType
}

// DeploymentProcessor gets the deployment processor for this controller.
func (b *BaseController) DeploymentProcessor() deployment.DeploymentProcessor {
return b.options.GetDeploymentProcessor()
}

// DeploymentProcessor gets the deployment processor for this controller.
func (b *BaseController) StatusManager() sm.StatusManager {
return b.options.StatusManager
Expand Down
2 changes: 1 addition & 1 deletion pkg/corerp/backend/deployment/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func buildMongoDBResourceDataWithRecipeAndSecrets() ResourceData {
return ResourceData{
ID: getTestResourceID(testResource.ID),
OutputResources: outputResources,
Resource: testResource,
Resource: &testResource,
ComputedValues: computedValues,
SecretValues: secretValues,
RecipeData: testResource.RecipeData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ func (src *DaprInvokeHTTPRouteResource) ConvertTo() (v1.DataModelInterface, erro
Tags: to.StringMap(src.Tags),
},
InternalMetadata: v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState),
},
},
Properties: datamodel.DaprInvokeHttpRouteProperties{
BasicResourceProperties: rp.BasicResourceProperties{
Environment: to.String(src.Properties.Environment),
Application: to.String(src.Properties.Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState),
AppId: to.String(src.Properties.AppID),
AppId: to.String(src.Properties.AppID),
},
}

Expand Down Expand Up @@ -62,7 +62,7 @@ func (dst *DaprInvokeHTTPRouteResource) ConvertFrom(src v1.DataModelInterface) e
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprHttpRoute.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprHttpRoute.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprHttpRoute.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprHttpRoute.Properties.Environment),
Application: to.StringPtr(daprHttpRoute.Properties.Application),
AppID: to.StringPtr(daprHttpRoute.Properties.AppId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func (src *DaprPubSubBrokerResource) ConvertTo() (v1.DataModelInterface, error)
Environment: to.String(src.Properties.GetDaprPubSubBrokerProperties().Environment),
Application: to.String(src.Properties.GetDaprPubSubBrokerProperties().Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.GetDaprPubSubBrokerProperties().ProvisioningState),
Topic: to.String(src.Properties.GetDaprPubSubBrokerProperties().Topic),
Topic: to.String(src.Properties.GetDaprPubSubBrokerProperties().Topic),
}

trackedResource := v1.TrackedResource{
Expand All @@ -34,7 +33,8 @@ func (src *DaprPubSubBrokerResource) ConvertTo() (v1.DataModelInterface, error)
Tags: to.StringMap(src.Tags),
}
internalMetadata := v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.GetDaprPubSubBrokerProperties().ProvisioningState),
}
converted := &datamodel.DaprPubSubBroker{}
converted.TrackedResource = trackedResource
Expand Down Expand Up @@ -95,7 +95,7 @@ func (dst *DaprPubSubBrokerResource) ConvertFrom(src v1.DataModelInterface) erro
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprPubSub.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprPubSub.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprPubSub.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprPubSub.Properties.Environment),
Application: to.StringPtr(daprPubSub.Properties.Application),
ComponentName: to.StringPtr(daprPubSub.Properties.ComponentName),
Expand All @@ -112,7 +112,7 @@ func (dst *DaprPubSubBrokerResource) ConvertFrom(src v1.DataModelInterface) erro
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprPubSub.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprPubSub.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprPubSub.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprPubSub.Properties.Environment),
Application: to.StringPtr(daprPubSub.Properties.Application),
ComponentName: to.StringPtr(daprPubSub.Properties.ComponentName),
Expand All @@ -127,7 +127,7 @@ func (dst *DaprPubSubBrokerResource) ConvertFrom(src v1.DataModelInterface) erro
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprPubSub.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprPubSub.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprPubSub.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprPubSub.Properties.Environment),
Application: to.StringPtr(daprPubSub.Properties.Application),
ComponentName: to.StringPtr(daprPubSub.Properties.ComponentName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func (src *DaprSecretStoreResource) ConvertTo() (v1.DataModelInterface, error) {
Tags: to.StringMap(src.Tags),
},
InternalMetadata: v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.GetDaprSecretStoreProperties().ProvisioningState),
},
},
Properties: datamodel.DaprSecretStoreProperties{
BasicResourceProperties: rp.BasicResourceProperties{
Environment: to.String(src.Properties.GetDaprSecretStoreProperties().Environment),
Application: to.String(src.Properties.GetDaprSecretStoreProperties().Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.GetDaprSecretStoreProperties().ProvisioningState),
},
}
switch v := src.Properties.(type) {
Expand Down Expand Up @@ -82,7 +82,7 @@ func (dst *DaprSecretStoreResource) ConvertFrom(src v1.DataModelInterface) error
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprSecretStore.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprSecretStore.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprSecretStore.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprSecretStore.Properties.Environment),
Application: to.StringPtr(daprSecretStore.Properties.Application),
Mode: &mode,
Expand All @@ -99,7 +99,7 @@ func (dst *DaprSecretStoreResource) ConvertFrom(src v1.DataModelInterface) error
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprSecretStore.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprSecretStore.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprSecretStore.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprSecretStore.Properties.Environment),
Application: to.StringPtr(daprSecretStore.Properties.Application),
Mode: &mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func (src *DaprStateStoreResource) ConvertTo() (v1.DataModelInterface, error) {
Environment: to.String(src.Properties.GetDaprStateStoreProperties().Environment),
Application: to.String(src.Properties.GetDaprStateStoreProperties().Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.GetDaprStateStoreProperties().ProvisioningState),
}

trackedResource := v1.TrackedResource{
Expand All @@ -28,7 +27,8 @@ func (src *DaprStateStoreResource) ConvertTo() (v1.DataModelInterface, error) {
Tags: to.StringMap(src.Tags),
}
internalMetadata := v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.GetDaprStateStoreProperties().ProvisioningState),
}
converted := &datamodel.DaprStateStore{}
converted.TrackedResource = trackedResource
Expand Down Expand Up @@ -88,7 +88,7 @@ func (dst *DaprStateStoreResource) ConvertFrom(src v1.DataModelInterface) error
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprStateStore.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprStateStore.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprStateStore.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprStateStore.Properties.Environment),
Application: to.StringPtr(daprStateStore.Properties.Application),
ComponentName: to.StringPtr(daprStateStore.Properties.ComponentName),
Expand All @@ -104,7 +104,7 @@ func (dst *DaprStateStoreResource) ConvertFrom(src v1.DataModelInterface) error
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprStateStore.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprStateStore.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprStateStore.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprStateStore.Properties.Environment),
Application: to.StringPtr(daprStateStore.Properties.Application),
ComponentName: to.StringPtr(daprStateStore.Properties.ComponentName),
Expand All @@ -118,7 +118,7 @@ func (dst *DaprStateStoreResource) ConvertFrom(src v1.DataModelInterface) error
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(daprStateStore.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(daprStateStore.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(daprStateStore.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(daprStateStore.Properties.Environment),
Application: to.StringPtr(daprStateStore.Properties.Application),
ComponentName: to.StringPtr(daprStateStore.Properties.ComponentName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func (src *ExtenderResource) ConvertTo() (v1.DataModelInterface, error) {
Tags: to.StringMap(src.Tags),
},
InternalMetadata: v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState),
},
},
Properties: datamodel.ExtenderProperties{
BasicResourceProperties: rp.BasicResourceProperties{
Environment: to.String(src.Properties.Environment),
Application: to.String(src.Properties.Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState),
AdditionalProperties: src.Properties.AdditionalProperties,
Secrets: src.Properties.Secrets,
},
Expand All @@ -58,7 +58,7 @@ func (dst *ExtenderResource) ConvertFrom(src v1.DataModelInterface) error {
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(extender.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(extender.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(extender.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(extender.Properties.Environment),
Application: to.StringPtr(extender.Properties.Application),
AdditionalProperties: extender.Properties.AdditionalProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func (src *MongoDatabaseResource) ConvertTo() (v1.DataModelInterface, error) {
Tags: to.StringMap(src.Tags),
},
InternalMetadata: v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.GetMongoDatabaseProperties().ProvisioningState),
},
},
Properties: datamodel.MongoDatabaseProperties{
BasicResourceProperties: rp.BasicResourceProperties{
Environment: to.String(src.Properties.GetMongoDatabaseProperties().Environment),
Application: to.String(src.Properties.GetMongoDatabaseProperties().Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.GetMongoDatabaseProperties().ProvisioningState),
},
}
switch v := src.Properties.(type) {
Expand Down Expand Up @@ -89,7 +89,7 @@ func (src *MongoDatabaseResource) ConvertTo() (v1.DataModelInterface, error) {
}
}
default:
return datamodel.MongoDatabase{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("Unsupported mode %s", *src.Properties.GetMongoDatabaseProperties().Mode))
return &datamodel.MongoDatabase{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("Unsupported mode %s", *src.Properties.GetMongoDatabaseProperties().Mode))
}
return converted, nil
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func (dst *MongoDatabaseResource) ConvertFrom(src v1.DataModelInterface) error {
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(mongo.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(mongo.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(mongo.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(mongo.Properties.Environment),
Application: to.StringPtr(mongo.Properties.Application),
}
Expand All @@ -134,7 +134,7 @@ func (dst *MongoDatabaseResource) ConvertFrom(src v1.DataModelInterface) error {
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(mongo.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(mongo.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(mongo.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(mongo.Properties.Environment),
Application: to.StringPtr(mongo.Properties.Application),
}
Expand All @@ -149,7 +149,7 @@ func (dst *MongoDatabaseResource) ConvertFrom(src v1.DataModelInterface) error {
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(mongo.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(mongo.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(mongo.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(mongo.Properties.Environment),
Application: to.StringPtr(mongo.Properties.Application),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func (src *RabbitMQMessageQueueResource) ConvertTo() (v1.DataModelInterface, err
Tags: to.StringMap(src.Tags),
},
InternalMetadata: v1.InternalMetadata{
UpdatedAPIVersion: Version,
UpdatedAPIVersion: Version,
AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.GetRabbitMQMessageQueueProperties().ProvisioningState),
},
},
Properties: datamodel.RabbitMQMessageQueueProperties{
BasicResourceProperties: rp.BasicResourceProperties{
Environment: to.String(src.Properties.GetRabbitMQMessageQueueProperties().Environment),
Application: to.String(src.Properties.GetRabbitMQMessageQueueProperties().Application),
},
ProvisioningState: toProvisioningStateDataModel(src.Properties.GetRabbitMQMessageQueueProperties().ProvisioningState),
},
}
switch v := src.Properties.(type) {
Expand Down Expand Up @@ -83,7 +83,7 @@ func (dst *RabbitMQMessageQueueResource) ConvertFrom(src v1.DataModelInterface)
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(rabbitmq.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(rabbitmq.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(rabbitmq.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(rabbitmq.Properties.Environment),
Application: to.StringPtr(rabbitmq.Properties.Application),
Mode: &mode,
Expand All @@ -97,7 +97,7 @@ func (dst *RabbitMQMessageQueueResource) ConvertFrom(src v1.DataModelInterface)
Status: &ResourceStatus{
OutputResources: rp.BuildExternalOutputResources(rabbitmq.Properties.Status.OutputResources),
},
ProvisioningState: fromProvisioningStateDataModel(rabbitmq.Properties.ProvisioningState),
ProvisioningState: fromProvisioningStateDataModel(rabbitmq.InternalMetadata.AsyncProvisioningState),
Environment: to.StringPtr(rabbitmq.Properties.Environment),
Application: to.StringPtr(rabbitmq.Properties.Application),
Mode: &mode,
Expand Down
Loading