summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDavid Herberth <github@dav1d.de>2021-08-03 23:56:28 +0200
committerGitHub <noreply@github.com>2021-08-03 23:56:28 +0200
commitcd6fc9cea0a410a588d09971cca07b2d815353ea (patch)
treebfe70e43faa2a43776c7ee5b75e77d9a770bd2c9 /docs
parent43a86f1a292527487809167453de4ac94bdf6adc (diff)
feat(kubernetes): implements regex matching for context aliases (#2883)
Diffstat (limited to 'docs')
-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