mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
Feat(cli): app status more info (#2937)
* Feat(cli): app status more info Signed-off-by: wangyike <wangyike_wyk@163.com> * more info Signed-off-by: wangyike <wangyike_wyk@163.com> * fix: delete invisible check Signed-off-by: wangyike <wangyike_wyk@163.com>
This commit is contained in:
@@ -755,10 +755,6 @@ func (h *Handler) checkDependencies() error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to find dependent addon in source repository")
|
||||
}
|
||||
if !depAddon.Invisible {
|
||||
return fmt.Errorf("dependent addon %s cannot be enabled automatically", depAddon.Name)
|
||||
}
|
||||
// invisible addon SHOULD be enabled without argument
|
||||
depHandler := *h
|
||||
depHandler.addon = depAddon
|
||||
depHandler.args = nil
|
||||
|
||||
@@ -364,10 +364,14 @@ func (u *addonUsecaseImpl) EnableAddon(ctx context.Context, name string, args ap
|
||||
if addon, exist = u.tryGetAddonFromCache(r.Name, name); !exist {
|
||||
addon, err = SourceOf(*r).GetAddon(name, pkgaddon.EnableLevelOptions)
|
||||
}
|
||||
if err != nil && !errors.Is(err, pkgaddon.ErrNotExist) {
|
||||
return bcode.WrapGithubRateLimitErr(err)
|
||||
|
||||
if err != nil {
|
||||
// one registry return error, should not break other registry func
|
||||
continue
|
||||
}
|
||||
if addon == nil {
|
||||
|
||||
// cannot find this addon in the registry
|
||||
if addon == nil || len(addon.Name) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
+13
-7
@@ -54,9 +54,12 @@ const (
|
||||
AddonTerraformProviderNameArgument = "providerName"
|
||||
)
|
||||
|
||||
var statusUninstalled = "uninstalled"
|
||||
var statusEnabled = "enabled"
|
||||
var statusEnabling = "enabling"
|
||||
const (
|
||||
statusUninstalled = "uninstalled"
|
||||
statusEnabled = "enabled"
|
||||
statusEnabling = "enabling"
|
||||
)
|
||||
|
||||
var clt client.Client
|
||||
var clientArgs common.Args
|
||||
|
||||
@@ -232,10 +235,13 @@ func enableAddon(ctx context.Context, k8sClient client.Client, config *rest.Conf
|
||||
source = registry.Git
|
||||
}
|
||||
addon, err = source.GetAddon(name, pkgaddon.EnableLevelOptions)
|
||||
if err != nil && !errors.Is(err, pkgaddon.ErrNotExist) {
|
||||
return err
|
||||
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if addon == nil {
|
||||
|
||||
// cannot find this addon in the registry
|
||||
if addon == nil || addon.Name == "" {
|
||||
continue
|
||||
}
|
||||
err = pkgaddon.EnableAddon(ctx, addon, k8sClient, apply.NewAPIApplicator(k8sClient), config, source, args)
|
||||
@@ -264,7 +270,7 @@ func statusAddon(name string) error {
|
||||
}
|
||||
fmt.Printf("addon %s status is %s \n", name, status)
|
||||
if status == statusEnabling {
|
||||
fmt.Printf("please check addon related application: namespace: %s name: %s", types.DefaultKubeVelaNS, pkgaddon.Convert2AppName(name))
|
||||
fmt.Printf("this addon is still enabling, please run \"vela status %s -n vela-system \" to check the status of the addon related app", pkgaddon.Convert2AppName(name))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -129,8 +129,11 @@ func printAppStatus(_ context.Context, c client.Client, ioStreams cmdutil.IOStre
|
||||
table.AddRow(" Name:", appName)
|
||||
table.AddRow(" Namespace:", namespace)
|
||||
table.AddRow(" Created at:", app.CreationTimestamp.String())
|
||||
table.AddRow(" Status:", getAppPhaseColor(app.Status.Phase).Sprint(app.Status.Phase))
|
||||
cmd.Printf("%s\n\n", table.String())
|
||||
|
||||
if err := printWorkflowStatus(c, ioStreams, appName, namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.Printf("Services:\n\n")
|
||||
return loopCheckStatus(c, ioStreams, appName, namespace)
|
||||
}
|
||||
@@ -153,6 +156,29 @@ func getComponentType(app *v1beta1.Application, name string) string {
|
||||
return "webservice"
|
||||
}
|
||||
|
||||
func printWorkflowStatus(c client.Client, ioStreams cmdutil.IOStreams, appName string, namespace string) error {
|
||||
remoteApp, err := loadRemoteApplication(c, namespace, appName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
workflowStatus := remoteApp.Status.Workflow
|
||||
ioStreams.Info("Workflow:\n")
|
||||
ioStreams.Infof(" mode: %s\n", workflowStatus.Mode)
|
||||
ioStreams.Infof(" finished: %t\n", workflowStatus.Finished)
|
||||
ioStreams.Infof(" Suspend: %t\n", workflowStatus.Suspend)
|
||||
ioStreams.Infof(" Terminated: %t\n", workflowStatus.Terminated)
|
||||
ioStreams.Info(" Steps")
|
||||
for _, step := range workflowStatus.Steps {
|
||||
ioStreams.Infof(" - id:%s\n", step.ID)
|
||||
ioStreams.Infof(" name:%s\n", step.Name)
|
||||
ioStreams.Infof(" type:%s\n", step.Type)
|
||||
ioStreams.Infof(" phase:%s \n", getWfStepColor(step.Phase).Sprint(step.Phase))
|
||||
ioStreams.Infof(" message:%s\n", step.Message)
|
||||
}
|
||||
ioStreams.Infof("\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
func loopCheckStatus(c client.Client, ioStreams cmdutil.IOStreams, appName string, namespace string) error {
|
||||
remoteApp, err := loadRemoteApplication(c, namespace, appName)
|
||||
if err != nil {
|
||||
@@ -254,3 +280,21 @@ func getHealthStatusColor(s bool) *color.Color {
|
||||
}
|
||||
return yellow
|
||||
}
|
||||
|
||||
func getWfStepColor(phase commontypes.WorkflowStepPhase) *color.Color {
|
||||
switch phase {
|
||||
case commontypes.WorkflowStepPhaseSucceeded:
|
||||
return green
|
||||
case commontypes.WorkflowStepPhaseFailed:
|
||||
return red
|
||||
default:
|
||||
return yellow
|
||||
}
|
||||
}
|
||||
|
||||
func getAppPhaseColor(appPhase commontypes.ApplicationPhase) *color.Color {
|
||||
if appPhase == commontypes.ApplicationRunning {
|
||||
return green
|
||||
}
|
||||
return yellow
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user