Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit b8fabd3

Browse files
committed
fix(plugins/plugin-core-support): up output does not clarify which service is being presented
This is regarding the ASCII output.
1 parent 5707d3d commit b8fabd3

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

plugins/plugin-core-support/up/src/kubernetes/kubectl.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
// import colors from 'colors/safe'
17+
import colors from 'colors/safe'
1818
import { Arguments } from '@kui-shell/core'
1919
import { doExecWithStdoutViaPty } from '@kui-shell/plugin-bash-like'
2020

@@ -35,9 +35,8 @@ async function check(args: Arguments) {
3535
export default {
3636
service,
3737
group: Group.CLI,
38-
label: 'kubectl',
39-
// (checkResult?: false | string) =>
40-
// checkResult === undefined ? 'Installed' : !checkResult ? 'not installed' : colors.gray(checkResult),
38+
label: (checkResult?: false | string) =>
39+
checkResult === undefined ? 'kubectl' : !checkResult ? 'not installed' : colors.gray(checkResult),
4140
description: 'The kubectl CLI allows access to your Kubernetes clusters',
4241
check,
4342
fix:

plugins/plugin-core-support/up/src/kubernetes/valid-kubeconfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ async function check({ REPL }: Pick<Arguments, 'REPL'>) {
3232
export default {
3333
service,
3434
group: Group.Authorization,
35-
label: (checkResult?: false | string) =>
36-
checkResult === undefined
35+
label: (checkResult?: boolean | string) =>
36+
checkResult === undefined || checkResult === true
3737
? 'Connected to cluster'
3838
: !checkResult
3939
? 'no valid config found'

plugins/plugin-core-support/up/src/ui.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Observable, Observer } from 'rxjs'
2020
import { Arguments, Streamable } from '@kui-shell/core'
2121

2222
import Options from './options'
23+
import Provider from './Provider'
2324
import checkers from './registrar'
2425
import Group, { GroupPriority } from './Group'
2526
import Checker, { CheckerArgs, CheckResult, Stdout } from './Checker'
@@ -34,19 +35,27 @@ export function success() {
3435
return ` ${colors.green('\u2713')}`
3536
}
3637

37-
export function formatLabel<T extends CheckResult>(label: Checker['label'], checkResult: T): string {
38+
export function formatLabel<T extends CheckResult>({ label, service }: Checker, checkResult: T, color = true): string {
3839
const labelText = typeof label === 'string' ? label : label(checkResult)
3940

40-
return labelText // .replace(/^([^:]+:)/, (_, p1) => colors.cyan(p1))
41+
const A = Provider[service.provider]
42+
const B = service.label
43+
const C = labelText
44+
45+
const AA = color ? colors.dim(colors.blue(A)) : A
46+
const BB = color ? colors.dim(colors.blue(B)) : B
47+
const CC = C
48+
49+
return `${AA}${BB ? ` ${BB}` : ''}: ${CC}` // .replace(/^([^:]+:)/, (_, p1) => colors.cyan(p1))
4150
}
4251

4352
type Status = { ok: boolean; message: string }
4453

45-
async function toStatus({ label }: Checker, checkResultP: ReturnType<Checker['check']>): Promise<Status> {
54+
async function toStatus(checker: Checker, checkResultP: ReturnType<Checker['check']>): Promise<Status> {
4655
const checkResult = await checkResultP
4756
return {
4857
ok: typeof checkResult === 'string' || checkResult === true,
49-
message: formatLabel(label, checkResult)
58+
message: formatLabel(checker, checkResult)
5059
}
5160
}
5261

@@ -99,7 +108,7 @@ function listrTaskForChecker(
99108
) {
100109
return (_: Checker, tidx: number) => {
101110
const idx = gidx + tidx
102-
const title = formatLabel(_.label, undefined)
111+
const title = formatLabel(_, undefined)
103112

104113
return {
105114
title,
@@ -154,7 +163,7 @@ export async function checkPrerequistes(
154163
task.newListr(
155164
checkers(args)
156165
.filter(_ => _.group === Group[group])
157-
.sort((a, b) => formatLabel(a.label, undefined).localeCompare(formatLabel(b.label, undefined)))
166+
.sort((a, b) => formatLabel(a, undefined).localeCompare(formatLabel(b, undefined)))
158167
.map(listrTaskForChecker(args, stdout, fixErrors, gidx * nGroups)),
159168
options
160169
)

0 commit comments

Comments
 (0)