Skip to content

Commit

Permalink
Fixes radius-project#7391 - fixing error in rad group show for no args
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Beenham <1985327+superbeeny@users.noreply.github.com>
  • Loading branch information
superbeeny committed Aug 28, 2024
1 parent 33d3d5e commit 5c7cbba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/cli/cmd/group/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"github.com/radius-project/radius/pkg/cli/framework"
"github.com/radius-project/radius/pkg/cli/output"
"github.com/radius-project/radius/pkg/cli/workspaces"
"github.com/radius-project/radius/pkg/ucp/resources"
resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -99,9 +101,18 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
if format == "" {
format = "table"
}
resourcegroup, err := cli.RequireUCPResourceGroup(cmd, args)
if err != nil {
return err
var resourcegroup string
if len(args) == 1 {
resourcegroup, err = cli.RequireUCPResourceGroup(cmd, args)
if err != nil {
return err
}
} else {
id, err := resources.ParseScope(workspace.Scope)
if err != nil {
return err
}
resourcegroup = id.FindScope(resources_radius.ScopeResourceGroups)
}

r.Format = format
Expand Down
9 changes: 9 additions & 0 deletions pkg/cli/cmd/group/show/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ func Test_Validate(t *testing.T) {
configWithWorkspace := radcli.LoadConfigWithWorkspace(t)

testcases := []radcli.ValidateInput{
{
Name: "Show Command with no args",
Input: []string{},
ExpectedValid: true,
ConfigHolder: framework.ConfigHolder{
ConfigFilePath: "",
Config: configWithWorkspace,
},
},
{
Name: "Show Command with incorrect args",
Input: []string{""},
Expand Down

0 comments on commit 5c7cbba

Please sign in to comment.