From a787a1a934dd00596c70619dc99c285e0c4ff894 Mon Sep 17 00:00:00 2001 From: Mike Sawka Date: Tue, 16 Apr 2024 13:22:58 -0700 Subject: [PATCH] add k8s context/namespace to prompt (#576) * k8s in prompt * test/fix formatting --- src/app/common/prompt/prompt.less | 4 ++++ src/app/common/prompt/prompt.tsx | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/common/prompt/prompt.less b/src/app/common/prompt/prompt.less index a56cac4ed..8621f6fba 100644 --- a/src/app/common/prompt/prompt.less +++ b/src/app/common/prompt/prompt.less @@ -58,4 +58,8 @@ .term-prompt-python { color: var(--term-magenta); } + + .term-prompt-k8s { + color: var(--term-magenta); + } } diff --git a/src/app/common/prompt/prompt.tsx b/src/app/common/prompt/prompt.tsx index eb1bde89d..d2e544a3a 100644 --- a/src/app/common/prompt/prompt.tsx +++ b/src/app/common/prompt/prompt.tsx @@ -146,6 +146,7 @@ class Prompt extends React.Component< let branchElem = null; let pythonElem = null; let condaElem = null; + let k8sElem = null; if (!isBlank(festate["PROMPTVAR_GITBRANCH"])) { const branchName = festate["PROMPTVAR_GITBRANCH"]; branchElem = ( @@ -171,9 +172,19 @@ class Prompt extends React.Component< ); } + if (!isBlank(festate["K8SCONTEXT"])) { + const k8sContext = festate["K8SCONTEXT"]; + const k8sNs = festate["K8SNAMESPACE"]; + k8sElem = ( + + k8s:({k8sContext} + {isBlank(k8sNs) ? "" : ":" + k8sNs}){" "} + + ); + } return ( - {remoteElem} {cwdElem} {branchElem} {condaElem} {pythonElem} + {remoteElem} {cwdElem} {branchElem} {condaElem} {pythonElem} {k8sElem} ); }