mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
Fix: skip endpoint table if no endpoints are found in addons (#4166)
* Feat: skip endpoint table if no endpoints are found in addons Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: rename function name Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: update tests to also exclude endpoints Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: reduce code changes Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"})
|
||||
|
||||
Reference in New Issue
Block a user