We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8205d57 commit 75113cdCopy full SHA for 75113cd
1 file changed
scripts/dev/rename-kubeconfig-ctx.jq
@@ -1,4 +1,11 @@
1
#!/usr/bin/env -S jq -f
2
+#
3
+# Pass JSON kubeconfig to this jq script to rename
4
+# the contexts to the referenced cluster names,
5
+# and the cluster names to the referenced user names.
6
+# This should help to merge kubeconfigs with non-unique
7
+# contexts and user names.
8
9
. as $cfg
10
| (
11
# Build context_map as an array of objects with name transformations.
@@ -8,7 +15,11 @@
15
cluster: .context.cluster,
16
old_user: .context.user,
17
new_name: .context.cluster,
- new_user: (.context.user + "@" + .context.cluster)
18
+ new_user: (.context as $ctx
19
+ | .context.user
20
+ | (if endswith($ctx.cluster)
21
+ then . else (. + "@" + $ctx.cluster) end)
22
+ )
12
23
})
13
24
) as $context_map
14
25
# Reconstruct the config from scratch.
0 commit comments