handleWatchStatusCommand displays the current K8s watcher status.
(ctx context.Context)
| 145 | |
| 146 | // handleWatchStatusCommand displays the current K8s watcher status. |
| 147 | func (ch *CommandHandler) handleWatchStatusCommand(ctx context.Context) { |
| 148 | // Check local watcher first |
| 149 | if ch.cli.isWatching { |
| 150 | if ch.cli.watchStatusFunc != nil { |
| 151 | status := ch.cli.watchStatusFunc() |
| 152 | fmt.Println(colorize(i18n.T("watch.status.active_with_info", status), ColorCyan)) |
| 153 | } else { |
| 154 | fmt.Println(colorize(i18n.T("watch.status.active_no_info"), ColorCyan)) |
| 155 | } |
| 156 | return |
| 157 | } |
| 158 | |
| 159 | // If connected to remote, query server's watcher status |
| 160 | if ch.cli.isRemote { |
| 161 | if rc, ok := ch.cli.Client.(*remote.Client); ok { |
| 162 | ctx, cancel := context.WithTimeout(ctx, 10*time.Second) |
| 163 | defer cancel() |
| 164 | ws, err := rc.GetWatcherStatus(ctx) |
| 165 | if err != nil { |
| 166 | fmt.Println(colorize(i18n.T("watch.error.remote_query_failed", err.Error()), ColorYellow)) |
| 167 | return |
| 168 | } |
| 169 | if !ws.Active { |
| 170 | fmt.Println(colorize(i18n.T("watch.status.remote_inactive"), ColorYellow)) |
| 171 | return |
| 172 | } |
| 173 | fmt.Println(colorize(i18n.T("watch.status.remote_active", ws.StatusSummary), ColorCyan)) |
| 174 | fmt.Println(colorize(i18n.T("watch.status.remote_details", |
| 175 | ws.Namespace, ws.Deployment, ws.PodCount, ws.AlertCount, ws.SnapshotCount), ColorCyan)) |
| 176 | return |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | fmt.Println(colorize(i18n.T("watch.status.inactive"), ColorYellow)) |
| 181 | } |
no test coverage detected