diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2021-03-05 15:46:49 +0100 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2021-03-05 15:46:49 +0100 |
| commit | 9e587a8cc4add8958753e9e477c0646ec6cb62c7 (patch) | |
| tree | 5c76ac530ba85abd1f7ad8d9f76f38fa14ff7a91 | |
| parent | 9a8a7b7d5a87b1ac588c00afe73a167a30c23865 (diff) | |
| download | gofu-ad21ddb7262f603c9e0084ceb43063ecad4aa7af.tar.gz | |
prettyprompt: visual warning when accessing a productive k8s clusterv2021.1
| -rw-r--r-- | internal/prompt/cloud.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/prompt/cloud.go b/internal/prompt/cloud.go index 807d2e2..42a2c39 100644 --- a/internal/prompt/cloud.go +++ b/internal/prompt/cloud.go @@ -1,6 +1,6 @@ /******************************************************************************* * -* Copyright 2017-2020 Stefan Majewsky <majewsky@gmx.net> +* Copyright 2017 Stefan Majewsky <majewsky@gmx.net> * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software @@ -55,11 +55,8 @@ func getKubernetesField() string { } namespace = "" } - if namespace != "" { - context += "/" + namespace - } - return withType("kube", context) + return buildKubernetesField(context, namespace) } func getKubernetesContext(configPath string) string { @@ -102,10 +99,17 @@ func getKubernetesFieldViaU8S() string { namespace = fields[1] } } + return buildKubernetesField(context, namespace) +} +func buildKubernetesField(context, namespace string) string { if context == "" { return "" } + if !strings.HasPrefix(context, "qa") { + //visual warning when working in a productive region + context = withColor("1;41", context) + } if namespace != "" { context += "/" + namespace } |
