From 35097fed454f4f7b8c18cec5bad056378d1f45a3 Mon Sep 17 00:00:00 2001 From: Itiel shwartz Date: Mon, 3 Oct 2022 23:34:28 +0300 Subject: [PATCH] Clean cluster name (#15) * support GKE and AWS cluster name * remove unused logs Co-authored-by: Itiel Shwartz --- pkg/dashboard/static/scripts.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/dashboard/static/scripts.js b/pkg/dashboard/static/scripts.js index 016ad4e..689593c 100644 --- a/pkg/dashboard/static/scripts.js +++ b/pkg/dashboard/static/scripts.js @@ -62,6 +62,20 @@ function statusStyle(status, card, txt) { } } +function getCleanClusterName(rawClusterName) { + if (rawClusterName.indexOf('arn')==0) { + // AWS cluster + clusterSplit = rawClusterName.split(':') + clusterName = clusterSplit.at(-1).split("/").at(-1) + region = clusterSplit.at(-3) + return region + "/" + clusterName + ' [AWS]' + } + if (rawClusterName.indexOf('gke')==0) { + // GKE cluster + return rawClusterName.split('_').at(-2) + '/' + rawClusterName.split('_').at(-1) + ' [GKE]' + } + return rawClusterName +} function fillClusterList(data, context) { data.forEach(function (elm) { @@ -71,7 +85,7 @@ function fillClusterList(data, context) { let opt = $('
  • '); opt.attr('title', label) opt.find("input").val(elm.Name).text(label) - opt.find("span").text(label) + opt.find("span").text(getCleanClusterName(label)) if (elm.IsCurrent && !context) { opt.find("input").prop("checked", true) setCurrentContext(elm.Name)