diff --git a/e2e/addon/addon_test.go b/e2e/addon/addon_test.go index ff1f93d0c..17144fc5a 100644 --- a/e2e/addon/addon_test.go +++ b/e2e/addon/addon_test.go @@ -87,7 +87,6 @@ var _ = Describe("Addon Test", func() { output, err := e2e.LongTimeExec("vela addon enable ../../e2e/addon/mock/testdata/sample/.", 600*time.Second) Expect(err).NotTo(HaveOccurred()) Expect(output).To(ContainSubstring("sample enabled successfully.")) - Expect(output).To(ContainSubstring("access sample from")) }) It("Test Change default namespace can work", func() { diff --git a/references/cli/addon.go b/references/cli/addon.go index 0df0d4f88..aac6c5e5d 100644 --- a/references/cli/addon.go +++ b/references/cli/addon.go @@ -199,7 +199,7 @@ Enable addon for specific clusters, (local means control plane): // AdditionalEndpointPrinter will print endpoints func AdditionalEndpointPrinter(ctx context.Context, c common.Args, k8sClient client.Client, name string, isUpgrade bool) { fmt.Printf("Please access %s from the following endpoints:\n", name) - err := printAppEndpoints(ctx, pkgaddon.Convert2AppName(name), types.DefaultKubeVelaNS, Filter{}, c) + err := printAppEndpoints(ctx, pkgaddon.Convert2AppName(name), types.DefaultKubeVelaNS, Filter{}, c, true) if err != nil { fmt.Println("Get application endpoints error:", err) return diff --git a/references/cli/status.go b/references/cli/status.go index f4fd1ab88..cd1562695 100644 --- a/references/cli/status.go +++ b/references/cli/status.go @@ -124,7 +124,7 @@ func NewAppStatusCommand(c common.Args, order string, ioStreams cmdutil.IOStream f := Filter{ Component: component, } - return printAppEndpoints(ctx, appName, namespace, f, c) + return printAppEndpoints(ctx, appName, namespace, f, c, false) } return printAppStatus(ctx, newClient, ioStreams, appName, namespace, cmd, c) }, @@ -163,7 +163,7 @@ func printAppStatus(_ context.Context, c client.Client, ioStreams cmdutil.IOStre return loopCheckStatus(c, ioStreams, appName, namespace) } -func printAppEndpoints(ctx context.Context, appName string, namespace string, f Filter, velaC common.Args) error { +func printAppEndpoints(ctx context.Context, appName string, namespace string, f Filter, velaC common.Args, skipEmptyTable bool) error { config, err := velaC.GetConfig() if err != nil { return err @@ -176,6 +176,9 @@ func printAppEndpoints(ctx context.Context, appName string, namespace string, f if err != nil { return err } + if skipEmptyTable && len(endpoints) == 0 { + return nil + } table := tablewriter.NewWriter(os.Stdout) table.SetColWidth(100) table.SetHeader([]string{"Cluster", "Component", "Ref(Kind/Namespace/Name)", "Endpoint"})