Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sk593 committed Sep 11, 2023
1 parent 62edc5c commit 2756cad
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 54 deletions.
5 changes: 0 additions & 5 deletions pkg/corerp/datamodel/extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ func (r *Extender) Recipe() *portableresources.ResourceRecipe {
return &r.Properties.ResourceRecipe
}

// SetDeploymentStatus updates the deployment status of the Extender resource.
func (r *Extender) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// ExtenderProperties represents the properties of Extender resource.
type ExtenderProperties struct {
rpv1.BasicResourceProperties
Expand Down
5 changes: 0 additions & 5 deletions pkg/daprrp/datamodel/daprpubsubbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ func (r *DaprPubSubBroker) Recipe() *portableresources.ResourceRecipe {
return &r.Properties.Recipe
}

// SetDeploymentStatus updates the deployment status of the Dapr Pub/Sub Broker resource.
func (r *DaprPubSubBroker) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// DaprPubSubBrokerProperties represents the properties of Dapr PubSubBroker resource.
type DaprPubSubBrokerProperties struct {
rpv1.BasicResourceProperties
Expand Down
5 changes: 0 additions & 5 deletions pkg/daprrp/datamodel/daprsecretstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ func (r *DaprSecretStore) ResourceTypeName() string {
return portableresources.DaprSecretStoresResourceType
}

// SetDeploymentStatus updates the deployment status of the Dapr SecretStore resource.
func (r *DaprSecretStore) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// DaprSecretStoreProperties represents the properties of DaprSecretStore resource.
type DaprSecretStoreProperties struct {
rpv1.BasicResourceProperties
Expand Down
5 changes: 0 additions & 5 deletions pkg/daprrp/datamodel/daprstatestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ func (r *DaprStateStore) Recipe() *portableresources.ResourceRecipe {
return &r.Properties.Recipe
}

// SetDeploymentStatus updates the deployment status of the DaprStateStore resource.
func (r *DaprStateStore) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// DaprStateStoreProperties represents the properties of DaprStateStore resource.
type DaprStateStoreProperties struct {
rpv1.BasicResourceProperties
Expand Down
5 changes: 0 additions & 5 deletions pkg/datastoresrp/datamodel/mongodatabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ func (r *MongoDatabase) Recipe() *portableresources.ResourceRecipe {
return &r.Properties.Recipe
}

// SetDeploymentStatus updates the deployment status of the Mongo database resource.
func (r *MongoDatabase) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// ResourceTypeName returns the resource type for Mongo database resource.
func (mongoSecrets *MongoDatabaseSecrets) ResourceTypeName() string {
return portableresources.MongoDatabasesResourceType
Expand Down
5 changes: 0 additions & 5 deletions pkg/datastoresrp/datamodel/rediscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ func (r *RedisCache) VerifyInputs() error {
return nil
}

// SetDeploymentStatus updates the deployment status of the Redis cache resource.
func (r *RedisCache) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

type RedisCacheProperties struct {
rpv1.BasicResourceProperties
// The host name of the target Redis cache
Expand Down
5 changes: 0 additions & 5 deletions pkg/datastoresrp/datamodel/sqldatabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ func (r *SqlDatabase) ResourceTypeName() string {
return portableresources.SqlDatabasesResourceType
}

// SetDeploymentStatus updates the deployment status of the SQL Databse resource.
func (r *SqlDatabase) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// SqlDatabaseProperties represents the properties of SQL database resource.
type SqlDatabaseProperties struct {
rpv1.BasicResourceProperties
Expand Down
5 changes: 0 additions & 5 deletions pkg/messagingrp/datamodel/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ func (r *RabbitMQQueue) ResourceTypeName() string {
return portableresources.RabbitMQQueuesResourceType
}

// SetDeploymentStatus updates the deployment status of the RabbitMQ resource.
func (r *RabbitMQQueue) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
r.Recipe().DeploymentStatus = status
}

// RabbitMQQueueProperties represents the properties of RabbitMQQueue response resource.
type RabbitMQQueueProperties struct {
rpv1.BasicResourceProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (c *CreateOrUpdateResource[P, T]) Run(ctx context.Context, req *ctrl.Reques
if err != nil {
if recipeError, ok := err.(*recipes.RecipeError); ok {
// Set the deployment status to the recipe error code.
recipeDataModel.SetDeploymentStatus(portableresources.RecipeDeploymentStatus(recipeError.DeploymentStatus))
recipeDataModel.Recipe().DeploymentStatus = portableresources.RecipeDeploymentStatus(recipeError.DeploymentStatus)
update := &store.Object{
Metadata: store.Metadata{
ID: req.ResourceID,
Expand Down Expand Up @@ -111,7 +111,7 @@ func (c *CreateOrUpdateResource[P, T]) Run(ctx context.Context, req *ctrl.Reques
return ctrl.Result{}, err
}

recipeDataModel.SetDeploymentStatus(portableresources.Success)
recipeDataModel.Recipe().DeploymentStatus = portableresources.Success
update := &store.Object{
Metadata: store.Metadata{
ID: req.ResourceID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ func (t *TestResource) Recipe() *portableresources.ResourceRecipe {
return &t.Properties.Recipe
}

// Recipe returns a pointer to the ResourceRecipe stored in the Properties field of the TestResource struct.
func (t *TestResource) SetDeploymentStatus(status portableresources.RecipeDeploymentStatus) {
t.Properties.Recipe.DeploymentStatus = status
}

type TestResourceProperties struct {
rpv1.BasicResourceProperties
IsProcessed bool `json:"isProcessed"`
Expand Down
2 changes: 0 additions & 2 deletions pkg/portableresources/datamodel/recipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ import (
type RecipeDataModel interface {
// Recipe provides access to the user-specified recipe configuration. Can return nil.
Recipe() *portableresources.ResourceRecipe
// SetDeploymentStatus updates the deployment status of the resource.
SetDeploymentStatus(status portableresources.RecipeDeploymentStatus)
}
6 changes: 3 additions & 3 deletions pkg/recipes/configloader/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ func (e *environmentLoader) LoadRecipe(ctx context.Context, recipe *recipes.Reso
func getRecipeDefinition(environment *v20220315privatepreview.EnvironmentResource, recipe *recipes.ResourceMetadata) (*recipes.EnvironmentDefinition, error) {
if environment.Properties.Recipes == nil {
msg := &recipes.ErrRecipeNotFound{Name: recipe.Name, Environment: recipe.EnvironmentID}
return nil, recipes.NewRecipeError(recipes.RecipeValidationFailed, msg.Error(), portableresources.RecipeSetupError, recipes.GetRecipeErrorDetails(msg))
return nil, recipes.NewRecipeError(recipes.RecipeNotFoundFailure, msg.Error(), portableresources.RecipeSetupError, recipes.GetRecipeErrorDetails(msg))
}

resource, err := resources.ParseResource(recipe.ResourceID)
if err != nil {
msg := fmt.Errorf("failed to parse resourceID: %q %w", recipe.ResourceID, err)
return nil, recipes.NewRecipeError(recipes.RecipeValidationFailed, msg.Error(), portableresources.RecipeSetupError, recipes.GetRecipeErrorDetails(msg))
return nil, recipes.NewRecipeError(recipes.RecipeValidationFailed, err.Error(), portableresources.RecipeSetupError, recipes.GetRecipeErrorDetails(msg))
}
recipeName := recipe.Name
found, ok := environment.Properties.Recipes[resource.Type()][recipeName]
if !ok {
msg := &recipes.ErrRecipeNotFound{Name: recipe.Name, Environment: recipe.EnvironmentID}
return nil, recipes.NewRecipeError(recipes.RecipeValidationFailed, msg.Error(), portableresources.RecipeSetupError, recipes.GetRecipeErrorDetails(msg))
return nil, recipes.NewRecipeError(recipes.RecipeNotFoundFailure, msg.Error(), portableresources.RecipeSetupError, recipes.GetRecipeErrorDetails(msg))
}

definition := &recipes.EnvironmentDefinition{
Expand Down
2 changes: 1 addition & 1 deletion pkg/recipes/configloader/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestGetRecipeDefinition(t *testing.T) {
metadata.ResourceID = "invalid-id"
_, err := getRecipeDefinition(&envResource, &metadata)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to parse resourceID")
require.Contains(t, err.Error(), "'invalid-id' is not a valid resource id")
})

t.Run("recipe not found for the resource type", func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/recipes/errorcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ const (

// Used for errors encountered when getting recipe parameters.
RecipeGetMetadataFailed = "RecipeGetMetadataFailed"

// Used for errors when checking the existence of a recipe.
RecipeNotFoundFailure = "RecipeNotFoundFailure"
)
2 changes: 1 addition & 1 deletion test/functional/shared/resources/recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Test_Recipe_NotFound(t *testing.T) {
Code: "ResourceDeploymentFailure",
Details: []step.DeploymentErrorDetail{
{
Code: recipes.RecipeValidationFailed,
Code: recipes.RecipeNotFoundFailure,
MessageContains: "could not find recipe \"not found!\" in environment",
},
},
Expand Down

0 comments on commit 2756cad

Please sign in to comment.