summaryrefslogtreecommitdiffstats
path: root/docs/config/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/config/README.md')
-rw-r--r--docs/config/README.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/config/README.md b/docs/config/README.md
index a9962b7da..e4fe6b1de 100644
--- a/docs/config/README.md
+++ b/docs/config/README.md
@@ -1723,6 +1723,33 @@ format = 'on [⛵ $context \($namespace\)](dimmed green) '
disabled = false
[kubernetes.context_aliases]
"dev.local.cluster.k8s" = "dev"
+".*/openshift-cluster/.*" = "openshift"
+"gke_.*_(?P<cluster>[\\w-]+)" = "gke-$cluster"
+```
+
+#### Regex Matching
+
+Additional to simple aliasing, `context_aliases` also supports
+extended matching and renaming using regular expressions.
+
+The regular expression must match on the entire kube context,
+capture groups can be referenced using `$name` and `$N` in the replacement.
+This is more explained in the [regex crate](https://docs.rs/regex/1.5.4/regex/struct.Regex.html#method.replace) documentation.
+
+Long and automatically generated cluster names can be identified
+and shortened using regular expressions:
+
+```toml
+[kubernetes.context_aliases]
+# OpenShift contexts carry the namespace and user in the kube context: `namespace/name/user`:
+".*/openshift-cluster/.*" = "openshift"
+# Or better, to rename every OpenShift cluster at once:
+".*/(?P<cluster>[\\w-]+)/.*" = "$cluster"
+
+# Contexts from GKE, AWS and other cloud providers usually carry additional information, like the region/zone.
+# The following entry matches on the GKE format (`gke_projectname_zone_cluster-name`)
+# and renames every matching kube context into a more readable format (`gke-cluster-name`):
+"gke_.*_(?P<cluster>[\\w-]+)" = "gke-$cluster"
```
## Line Break