goharbor / harbor-cli

[Sandbox] Official Harbor CLI
Apache License 2.0
31 stars 37 forks source link

add health sub-command #82

Open KaivenBugwadia opened 3 months ago

KaivenBugwadia commented 3 months ago

As part of my application for the LFX mentorship project I have implemented a sample command.

This PR adds the health sub-command to display server and component statuses.

./harbor health
  Status: healthy
┌─────────────────────────────────────────────────────────────────────────┐
│  Component Name  Status               Error Message                     │
│ ─────────────────────────────────────────────────────────────────────── │
│  core            healthy                                                │
│  database        healthy                                                │
│  jobservice      healthy                                                │
│  portal          healthy                                                │
│  redis           healthy                                                │
│  registry        healthy                                                │
│  registryctl     healthy                                                │
│  trivy           healthy                                                │
└─────────────────────────────────────────────────────────────────────────┘

I also implemented the YAML output format, which was added for other commands by PR https://github.com/goharbor/harbor-cli/pull/74.

./harbor health -o yaml
components:
    - error: ""
      name: core
      status: healthy
    - error: ""
      name: database
      status: healthy
    - error: ""
      name: jobservice
      status: healthy
    - error: ""
      name: portal
      status: healthy
    - error: ""
      name: redis
      status: healthy
    - error: ""
      name: registry
      status: healthy
    - error: ""
      name: registryctl
      status: healthy
    - error: ""
      name: trivy
      status: healthy
status: healthy

Here is a GIF of the command in the CLI Harbor Health showcase