Skip to content

Commit

Permalink
make graph as default cmmand and connections as alias (#7217)
Browse files Browse the repository at this point in the history
# Description

Change "default" command to rad app graph, so that the auto-generated
docs use that instead of rad app connections.


## Type of change

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).


Fixes: #6473

---------

Signed-off-by: nithyatsu <[email protected]>
  • Loading branch information
nithyatsu authored Mar 4, 2024
1 parent c60867b commit d5f5a22
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cmd/rad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/radius-project/radius/pkg/cli/azure"
"github.com/radius-project/radius/pkg/cli/bicep"
"github.com/radius-project/radius/pkg/cli/clierrors"
app_connections "github.com/radius-project/radius/pkg/cli/cmd/app/connections"
app_delete "github.com/radius-project/radius/pkg/cli/cmd/app/delete"
app_graph "github.com/radius-project/radius/pkg/cli/cmd/app/graph"
app_list "github.com/radius-project/radius/pkg/cli/cmd/app/list"
app_show "github.com/radius-project/radius/pkg/cli/cmd/app/show"
app_status "github.com/radius-project/radius/pkg/cli/cmd/app/status"
Expand Down Expand Up @@ -283,8 +283,8 @@ func initSubCommands() {
appStatusCmd, _ := app_status.NewCommand(framework)
applicationCmd.AddCommand(appStatusCmd)

appConnectionsCmd, _ := app_connections.NewCommand(framework)
applicationCmd.AddCommand(appConnectionsCmd)
appGraphCmd, _ := app_graph.NewCommand(framework)
applicationCmd.AddCommand(appGraphCmd)

envSwitchCmd, _ := env_switch.NewCommand(framework)
envCmd.AddCommand(envSwitchCmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package connections
package graph

import (
"github.com/radius-project/radius/pkg/resourcemodel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package connections
package graph

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package connections
package graph

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package connections
package graph

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the MIT License.
// ------------------------------------------------------------

package connections
package graph

import (
"context"
Expand All @@ -20,21 +20,21 @@ import (
"github.com/spf13/cobra"
)

// NewCommand creates an instance of the command and runner for the `rad app connections` command.
// NewCommand creates an instance of the command and runner for the `rad app graph` command.
func NewCommand(factory framework.Factory) (*cobra.Command, framework.Runner) {
runner := NewRunner(factory)
cmd := &cobra.Command{
Use: "connections",
Aliases: []string{"graph"},
Short: "Shows the connections for an application.",
Long: `Shows the connections for an application`,
Use: "graph",
Aliases: []string{"connections"},
Short: "Shows the application graph for an application.",
Long: `Shows the application graph for an application.`,
Args: cobra.MaximumNArgs(1),
Example: `
# Show connections for current application
rad app connections
# Show graph for current application
rad app graph
# Show connections for specified application
rad app connections my-application`,
# Show graph for specified application
rad app graph my-application`,
RunE: framework.RunCommand(runner),
}

Expand All @@ -46,7 +46,7 @@ rad app connections my-application`,
return cmd, runner
}

// Runner is the runner implementation for the `rad app connections` command.
// Runner is the runner implementation for the `rad app graph` command.
type Runner struct {
ConfigHolder *framework.ConfigHolder
ConnectionFactory connections.Factory
Expand All @@ -57,7 +57,7 @@ type Runner struct {
Workspace *workspaces.Workspace
}

// NewRunner creates a new instance of the `rad app connections` runner.
// NewRunner creates a new instance of the `rad app graph` runner.
func NewRunner(factory framework.Factory) *Runner {
return &Runner{
ConfigHolder: factory.GetConfigHolder(),
Expand All @@ -66,7 +66,7 @@ func NewRunner(factory framework.Factory) *Runner {
}
}

// Validate runs validation for the `rad app connections` command.
// Validate runs validation for the `rad app graph` command.
func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
workspace, err := cli.RequireWorkspace(cmd, r.ConfigHolder.Config, r.ConfigHolder.DirectoryConfig)
if err != nil {
Expand Down Expand Up @@ -107,7 +107,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
return nil
}

// Run runs the `rad app connections` command.
// Run runs the `rad app graph` command.
func (r *Runner) Run(ctx context.Context) error {
client, err := r.ConnectionFactory.CreateApplicationsManagementClient(ctx, *r.Workspace)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the MIT License.
// ------------------------------------------------------------

package connections
package graph

import (
"context"
Expand Down Expand Up @@ -41,7 +41,7 @@ func Test_Validate(t *testing.T) {
configWithWorkspace := radcli.LoadConfigWithWorkspace(t)
testcases := []radcli.ValidateInput{
{
Name: "Connections command application (positional)",
Name: "Graph command application (positional)",
Input: []string{"test-app"},
ExpectedValid: true,
ConfigHolder: framework.ConfigHolder{
Expand All @@ -62,7 +62,7 @@ func Test_Validate(t *testing.T) {
},
},
{
Name: "Connections command application (flag)",
Name: "Graph command application (flag)",
Input: []string{"-a", "test-app"},
ExpectedValid: true,
ConfigHolder: framework.ConfigHolder{
Expand All @@ -83,7 +83,7 @@ func Test_Validate(t *testing.T) {
},
},
{
Name: "Connections command missing application",
Name: "Graph command missing application",
Input: []string{"-a", "test-app"},
ExpectedValid: false,
ConfigHolder: framework.ConfigHolder{
Expand All @@ -98,7 +98,7 @@ func Test_Validate(t *testing.T) {
},
},
{
Name: "Connections command with incorrect args",
Name: "Graph command with incorrect args",
Input: []string{"foo", "bar"},
ExpectedValid: false,
ConfigHolder: framework.ConfigHolder{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package connections
package graph

import (
corerpv20231001preview "github.com/radius-project/radius/pkg/corerp/api/v20231001preview"
Expand Down

0 comments on commit d5f5a22

Please sign in to comment.