From d5f5a22eb2c2188e0d65e6f5cbf329de255503c0 Mon Sep 17 00:00:00 2001 From: Nithya Subramanian <98416062+nithyatsu@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:28:03 -0800 Subject: [PATCH] make graph as default cmmand and connections as alias (#7217) # 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 --- cmd/rad/cmd/root.go | 6 ++-- .../cmd/app/{connections => graph}/compute.go | 2 +- .../{connections => graph}/compute_test.go | 2 +- .../cmd/app/{connections => graph}/display.go | 2 +- .../{connections => graph}/display_test.go | 2 +- .../connections.go => graph/graph.go} | 28 +++++++++---------- .../graph_test.go} | 10 +++---- .../{connections => graph}/shareddata_test.go | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) rename pkg/cli/cmd/app/{connections => graph}/compute.go (98%) rename pkg/cli/cmd/app/{connections => graph}/compute_test.go (98%) rename pkg/cli/cmd/app/{connections => graph}/display.go (99%) rename pkg/cli/cmd/app/{connections => graph}/display_test.go (99%) rename pkg/cli/cmd/app/{connections/connections.go => graph/graph.go} (82%) rename pkg/cli/cmd/app/{connections/connections_test.go => graph/graph_test.go} (96%) rename pkg/cli/cmd/app/{connections => graph}/shareddata_test.go (98%) diff --git a/cmd/rad/cmd/root.go b/cmd/rad/cmd/root.go index c95528e1c2..1320cb17a5 100644 --- a/cmd/rad/cmd/root.go +++ b/cmd/rad/cmd/root.go @@ -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" @@ -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) diff --git a/pkg/cli/cmd/app/connections/compute.go b/pkg/cli/cmd/app/graph/compute.go similarity index 98% rename from pkg/cli/cmd/app/connections/compute.go rename to pkg/cli/cmd/app/graph/compute.go index 6a25c4b113..46cdcfa46c 100644 --- a/pkg/cli/cmd/app/connections/compute.go +++ b/pkg/cli/cmd/app/graph/compute.go @@ -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" diff --git a/pkg/cli/cmd/app/connections/compute_test.go b/pkg/cli/cmd/app/graph/compute_test.go similarity index 98% rename from pkg/cli/cmd/app/connections/compute_test.go rename to pkg/cli/cmd/app/graph/compute_test.go index 90d421f20c..3a8904dec2 100644 --- a/pkg/cli/cmd/app/connections/compute_test.go +++ b/pkg/cli/cmd/app/graph/compute_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package connections +package graph import ( "testing" diff --git a/pkg/cli/cmd/app/connections/display.go b/pkg/cli/cmd/app/graph/display.go similarity index 99% rename from pkg/cli/cmd/app/connections/display.go rename to pkg/cli/cmd/app/graph/display.go index 2cbc8e2e44..6951484d5a 100644 --- a/pkg/cli/cmd/app/connections/display.go +++ b/pkg/cli/cmd/app/graph/display.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package connections +package graph import ( "fmt" diff --git a/pkg/cli/cmd/app/connections/display_test.go b/pkg/cli/cmd/app/graph/display_test.go similarity index 99% rename from pkg/cli/cmd/app/connections/display_test.go rename to pkg/cli/cmd/app/graph/display_test.go index 65741a1b75..58b85d50ae 100644 --- a/pkg/cli/cmd/app/connections/display_test.go +++ b/pkg/cli/cmd/app/graph/display_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package connections +package graph import ( "testing" diff --git a/pkg/cli/cmd/app/connections/connections.go b/pkg/cli/cmd/app/graph/graph.go similarity index 82% rename from pkg/cli/cmd/app/connections/connections.go rename to pkg/cli/cmd/app/graph/graph.go index dfe7850eda..68817887a1 100644 --- a/pkg/cli/cmd/app/connections/connections.go +++ b/pkg/cli/cmd/app/graph/graph.go @@ -3,7 +3,7 @@ // Licensed under the MIT License. // ------------------------------------------------------------ -package connections +package graph import ( "context" @@ -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), } @@ -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 @@ -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(), @@ -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 { @@ -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 { diff --git a/pkg/cli/cmd/app/connections/connections_test.go b/pkg/cli/cmd/app/graph/graph_test.go similarity index 96% rename from pkg/cli/cmd/app/connections/connections_test.go rename to pkg/cli/cmd/app/graph/graph_test.go index 7def5257d5..13cd207537 100644 --- a/pkg/cli/cmd/app/connections/connections_test.go +++ b/pkg/cli/cmd/app/graph/graph_test.go @@ -3,7 +3,7 @@ // Licensed under the MIT License. // ------------------------------------------------------------ -package connections +package graph import ( "context" @@ -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{ @@ -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{ @@ -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{ @@ -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{ diff --git a/pkg/cli/cmd/app/connections/shareddata_test.go b/pkg/cli/cmd/app/graph/shareddata_test.go similarity index 98% rename from pkg/cli/cmd/app/connections/shareddata_test.go rename to pkg/cli/cmd/app/graph/shareddata_test.go index baadb8dd03..d1fca7c073 100644 --- a/pkg/cli/cmd/app/connections/shareddata_test.go +++ b/pkg/cli/cmd/app/graph/shareddata_test.go @@ -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"