Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into willdavsmith/aws-patc…
Browse files Browse the repository at this point in the history
…h-update
  • Loading branch information
willdavsmith committed May 4, 2023
2 parents a7c9eed + 42a6f1b commit 420059d
Show file tree
Hide file tree
Showing 83 changed files with 892 additions and 483 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
* **extensions**: [EnvironmentExtension](#environmentextension)[]: Extensions spec of the resource
* **providers**: [Providers](#providers): Cloud providers configuration
* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called.
* **recipes**: [EnvironmentPropertiesRecipes](#environmentpropertiesrecipes): Dictionary of <EnvironmentRecipeProperties>
* **recipes**: [EnvironmentPropertiesRecipes](#environmentpropertiesrecipes): Specifies Recipes linked to the Environment.
* **useDevRecipes**: bool: Flag to use radius owned recipes.

## EnvironmentExtension
Expand Down Expand Up @@ -353,11 +353,15 @@
## EnvironmentPropertiesRecipes
### Properties
### Additional Properties
* **Additional Properties Type**: [DictionaryOfEnvironmentRecipeProperties](#dictionaryofenvironmentrecipeproperties)

## DictionaryOfEnvironmentRecipeProperties
### Properties
### Additional Properties
* **Additional Properties Type**: [EnvironmentRecipeProperties](#environmentrecipeproperties)

## EnvironmentRecipeProperties
### Properties
* **linkType**: string (Required): Type of the link this recipe can be consumed by. For example: 'Applications.Link/mongoDatabases'
* **parameters**: any: Any object
* **templatePath**: string (Required): Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported.

Expand Down
2 changes: 1 addition & 1 deletion hack/bicep-types-radius/generated/index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Resources":{"Applications.Core/environments@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":50},"Applications.Core/applications@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":74},"Applications.Core/httpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":88},"Applications.Core/gateways@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":106},"Applications.Core/containers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":171},"Applications.Core/volumes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":208},"Applications.Core/secretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":231},"Applications.Link/daprInvokeHttpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":35},"Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":55},"Applications.Link/daprSecretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":73},"Applications.Link/daprStateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":93},"Applications.Link/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":114},"Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":133},"Applications.Link/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":154},"Applications.Link/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":174},"Applications.Link/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":189}},"Functions":{"applications.core/secretstores":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":234}]},"applications.link/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":191}]},"applications.link/rabbitmqmessagequeues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":193}]},"applications.link/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":195}]},"applications.link/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":197}]}}}
{"Resources":{"Applications.Core/environments@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":51},"Applications.Core/applications@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":75},"Applications.Core/httpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":89},"Applications.Core/gateways@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":107},"Applications.Core/containers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":172},"Applications.Core/volumes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":209},"Applications.Core/secretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":232},"Applications.Link/daprInvokeHttpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":35},"Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":55},"Applications.Link/daprSecretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":73},"Applications.Link/daprStateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":93},"Applications.Link/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":114},"Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":133},"Applications.Link/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":154},"Applications.Link/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":174},"Applications.Link/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":189}},"Functions":{"applications.core/secretstores":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":235}]},"applications.link/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":191}]},"applications.link/rabbitmqmessagequeues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":193}]},"applications.link/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":195}]},"applications.link/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":197}]}}}
4 changes: 4 additions & 0 deletions pkg/armrpc/api/v1/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ type ErrClientRP struct {
func (r *ErrClientRP) Error() string {
return fmt.Sprintf("code %v: err %v", r.Code, r.Message)
}
func (e *ErrClientRP) Is(target error) bool {
_, ok := target.(*ErrClientRP)
return ok
}

func NewClientErrInvalidRequest(message string) *ErrClientRP {
err := new(ErrClientRP)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type ApplicationsManagementClient interface {
ListUCPGroup(ctx context.Context, planeType string, planeName string) ([]ucp_v20220901privatepreview.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, recipeName string) (corerp.EnvironmentRecipeProperties, error)
ShowRecipe(ctx context.Context, environmentName string, recipe corerp.Recipe) (corerp.EnvironmentRecipeProperties, error)
}

func ShallowCopy(params DeploymentParameters) DeploymentParameters {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/clients/mock_applicationsclient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/cli/clivalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type AzureResource struct {
SubscriptionID string
}

const (
LinkTypeFlag = "link-type"
)

func RequireEnvironmentNameArgs(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error) {
environmentName, err := ReadEnvironmentNameArgs(cmd, args)
if err != nil {
Expand Down Expand Up @@ -431,3 +435,11 @@ func RequireRecipeNameArgs(cmd *cobra.Command, args []string) (string, error) {
}
return args[0], nil
}

func RequireLinkType(cmd *cobra.Command) (string, error) {
linkType, err := cmd.Flags().GetString(LinkTypeFlag)
if err != nil {
return linkType, err
}
return linkType, nil
}
4 changes: 4 additions & 0 deletions pkg/cli/cmd/commonflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func AddParameterFlag(cmd *cobra.Command) {
cmd.Flags().StringArrayP("parameters", "p", []string{}, "Specify parameters for the deployment")
}

func AddLinkTypeFlag(cmd *cobra.Command) {
cmd.Flags().String("link-type", "", "Specify the type of the link this recipe can be consumed by")
}

func AddAzureScopeFlags(cmd *cobra.Command) {
AddAzureSubscriptionFlag(cmd)
AddAzureResourceGroupFlag(cmd)
Expand Down
13 changes: 7 additions & 6 deletions pkg/cli/cmd/recipe/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ func (r *Runner) Run(ctx context.Context) error {
return err
}
var envRecipes []EnvironmentRecipe
for recipeName, recipeProperties := range envResource.Properties.Recipes {
recipe := EnvironmentRecipe{
Name: recipeName,
LinkType: *recipeProperties.LinkType,
TemplatePath: *recipeProperties.TemplatePath,
for link, recipes := range envResource.Properties.Recipes {
for recipeName, recipeDetails := range recipes {
envRecipes = append(envRecipes, EnvironmentRecipe{
Name: recipeName,
LinkType: link,
TemplatePath: *recipeDetails.TemplatePath,
})
}
envRecipes = append(envRecipes, recipe)
}
err = r.Output.WriteFormatted(r.Format, envRecipes, objectformats.GetEnvironmentRecipesTableFormat())
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions pkg/cli/cmd/recipe/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ func Test_Run(t *testing.T) {
Type: to.Ptr("applications.core/environments"),
Location: to.Ptr(v1.LocationGlobal),
Properties: &v20220315privatepreview.EnvironmentProperties{
Recipes: map[string]*v20220315privatepreview.EnvironmentRecipeProperties{
"cosmosDB": {
LinkType: to.Ptr(linkrp.MongoDatabasesResourceType),
TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"),
Recipes: map[string]map[string]*v20220315privatepreview.EnvironmentRecipeProperties{
linkrp.MongoDatabasesResourceType: {
"cosmosDB": {
TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"),
},
},
},
},
Expand Down
35 changes: 14 additions & 21 deletions pkg/cli/cmd/recipe/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/project-radius/radius/pkg/cli/framework"
"github.com/project-radius/radius/pkg/cli/output"
"github.com/project-radius/radius/pkg/cli/workspaces"
corerpapps "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview"
corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -103,7 +103,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
}
r.TemplatePath = templatePath

linkType, err := requireLinkType(cmd)
linkType, err := cli.RequireLinkType(cmd)
if err != nil {
return err
}
Expand Down Expand Up @@ -139,22 +139,23 @@ func (r *Runner) Run(ctx context.Context) error {
return err
}

recipeProperties := envResource.Properties.Recipes
if recipeProperties == nil {
recipeProperties = map[string]*corerpapps.EnvironmentRecipeProperties{}
envRecipes := envResource.Properties.Recipes
if envRecipes == nil {
envRecipes = map[string]map[string]*corerp.EnvironmentRecipeProperties{}
}

if recipeProperties[r.RecipeName] != nil {
return &cli.FriendlyError{Message: fmt.Sprintf("recipe with name %q already exists in the environment %q", r.RecipeName, r.Workspace.Environment)}
}

recipeProperties[r.RecipeName] = &corerpapps.EnvironmentRecipeProperties{
LinkType: &r.LinkType,
properties := &corerp.EnvironmentRecipeProperties{
TemplatePath: &r.TemplatePath,
Parameters: bicep.ConvertToMapStringInterface(r.Parameters),
}

envResource.Properties.Recipes = recipeProperties
if val, ok := envRecipes[r.LinkType]; ok {
val[r.RecipeName] = properties
} else {
envRecipes[r.LinkType] = map[string]*corerp.EnvironmentRecipeProperties{
r.RecipeName: properties,
}
}
envResource.Properties.Recipes = envRecipes

isEnvCreated, err := client.CreateEnvironment(ctx, r.Workspace.Environment, v1.LocationGlobal, envResource.Properties)
if err != nil || !isEnvCreated {
Expand All @@ -173,11 +174,3 @@ func requireTemplatePath(cmd *cobra.Command) (string, error) {
return templatePath, nil

}

func requireLinkType(cmd *cobra.Command) (string, error) {
linkType, err := cmd.Flags().GetString("link-type")
if err != nil {
return linkType, err
}
return linkType, nil
}
Loading

0 comments on commit 420059d

Please sign in to comment.