From 9e587a8cc4add8958753e9e477c0646ec6cb62c7 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 5 Mar 2021 15:46:49 +0100 Subject: prettyprompt: visual warning when accessing a productive k8s cluster --- internal/prompt/cloud.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'internal/prompt/cloud.go') 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 +* Copyright 2017 Stefan Majewsky * * 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 } -- cgit v1.3.1