Skip to content

Commit

Permalink
Fix rad recipe show example
Browse files Browse the repository at this point in the history
  • Loading branch information
kachawla committed Oct 11, 2023
1 parent 03bd47b commit 7bf4dcd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion pkg/cli/clivalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ func RequireRecipeNameArgs(cmd *cobra.Command, args []string) (string, error) {
func GetResourceType(cmd *cobra.Command) (string, error) {
resourceType, err := cmd.Flags().GetString(ResourceTypeFlag)
if err != nil {
return resourceType, err
return "", err
}

return resourceType, nil
}
6 changes: 3 additions & 3 deletions pkg/cli/cmd/recipe/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ By default, the command is scoped to the resource group and environment defined
By default, the command outputs a human-readable table. You can customize the output format with the output flag.`,
Example: `
# show the details of a recipe
rad recipe show redis-prod
rad recipe show redis-prod --resource-type Applications.Datastores/redisCaches
# show the details of a recipe, with a JSON output
rad recipe show redis-prod --output json
rad recipe show redis-prod --resource-type Applications.Datastores/redisCaches --output json
# show the details of a recipe, with a specified environment and group
rad recipe show redis-dev --group dev --environment dev`,
rad recipe show redis-dev --resource-type Applications.Datastores/redisCaches --group dev --environment dev`,
RunE: framework.RunCommand(runner),
Args: cobra.ExactArgs(1),
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/cli/cmd/recipe/show/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/radius-project/radius/pkg/cli/output"
"github.com/radius-project/radius/pkg/cli/workspaces"
"github.com/radius-project/radius/pkg/corerp/api/v20231001preview"
ds_ctrl "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller"
datastorerp "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller"
"github.com/radius-project/radius/pkg/recipes"
"github.com/radius-project/radius/pkg/to"
"github.com/radius-project/radius/test/radcli"
Expand All @@ -46,7 +46,7 @@ func Test_Validate(t *testing.T) {
testcases := []radcli.ValidateInput{
{
Name: "Valid Show Command",
Input: []string{"recipeName", "--resource-type", "resource-type"},
Input: []string{"recipeName", "--resource-type", datastorerp.RedisCachesResourceType},
ExpectedValid: true,
ConfigHolder: framework.ConfigHolder{
ConfigFilePath: "",
Expand All @@ -55,7 +55,7 @@ func Test_Validate(t *testing.T) {
},
{
Name: "Show Command with incorrect fallback workspace",
Input: []string{"-e", "my-env", "-g", "my-env", "recipeName", "--resource-type", "resource-type"},
Input: []string{"-e", "my-env", "-g", "my-env", "recipeName", "--resource-type", datastorerp.RedisCachesResourceType},
ExpectedValid: false,
ConfigHolder: framework.ConfigHolder{
ConfigFilePath: "",
Expand All @@ -64,7 +64,7 @@ func Test_Validate(t *testing.T) {
},
{
Name: "Show Command with too many positional args",
Input: []string{"recipeName", "arg2", "--resource-type", "resource-type"},
Input: []string{"recipeName", "arg2", "--resource-type", datastorerp.RedisCachesResourceType},
ExpectedValid: false,
ConfigHolder: framework.ConfigHolder{
ConfigFilePath: "",
Expand All @@ -73,7 +73,7 @@ func Test_Validate(t *testing.T) {
},
{
Name: "Show Command with fallback workspace",
Input: []string{"-e", "my-env", "-w", "test-workspace", "recipeName", "--resource-type", "resource-type"},
Input: []string{"-e", "my-env", "-w", "test-workspace", "recipeName", "--resource-type", datastorerp.RedisCachesResourceType},
ExpectedValid: true,
ConfigHolder: framework.ConfigHolder{
ConfigFilePath: "",
Expand Down Expand Up @@ -111,7 +111,7 @@ func Test_Run(t *testing.T) {
}
recipe := types.EnvironmentRecipe{
Name: "cosmosDB",
ResourceType: ds_ctrl.MongoDatabasesResourceType,
ResourceType: datastorerp.MongoDatabasesResourceType,
TemplateKind: recipes.TemplateKindBicep,
TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1",
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func Test_Run(t *testing.T) {
Workspace: &workspaces.Workspace{},
Format: "table",
RecipeName: "cosmosDB",
ResourceType: ds_ctrl.MongoDatabasesResourceType,
ResourceType: datastorerp.MongoDatabasesResourceType,
}

err := runner.Run(context.Background())
Expand Down Expand Up @@ -187,7 +187,7 @@ func Test_Run(t *testing.T) {
}
recipe := types.EnvironmentRecipe{
Name: "cosmosDB",
ResourceType: ds_ctrl.MongoDatabasesResourceType,
ResourceType: datastorerp.MongoDatabasesResourceType,
TemplateKind: recipes.TemplateKindTerraform,
TemplatePath: "Azure/cosmosdb/azurerm",
TemplateVersion: "1.1.0",
Expand Down Expand Up @@ -222,7 +222,7 @@ func Test_Run(t *testing.T) {
Workspace: &workspaces.Workspace{},
Format: "table",
RecipeName: "cosmosDB",
ResourceType: ds_ctrl.MongoDatabasesResourceType,
ResourceType: datastorerp.MongoDatabasesResourceType,
}

err := runner.Run(context.Background())
Expand Down

0 comments on commit 7bf4dcd

Please sign in to comment.