Cosmetics

This commit is contained in:
Andrei Pohilko
2022-11-08 14:37:48 +00:00
parent 2454fcf47c
commit dadf2d1bde
6 changed files with 23 additions and 22 deletions

View File

@@ -15,7 +15,7 @@ pull: ; $(info $(M) Pulling source...) @
.PHONY: build .PHONY: build
build: $(BIN) ; $(info $(M) Building executable...) @ ## Build program binary build: $(BIN) ; $(info $(M) Building executable...) @ ## Build program binary
$Q $(GO) build \ go build \
-ldflags '-X main.version=$(VERSION) -X main.buildDate=$(DATE)' \ -ldflags '-X main.version=$(VERSION) -X main.buildDate=$(DATE)' \
-o bin/dashboard . -o bin/dashboard .

View File

@@ -39,6 +39,7 @@ func (h *KubeHandler) GetResourceInfo(c *gin.Context) {
return return
} }
// custom logic to provide most meaningful status for the resource
if res.Status.Phase == "Active" || res.Status.Phase == "Error" { if res.Status.Phase == "Active" || res.Status.Phase == "Error" {
_ = res.Name + "" _ = res.Name + ""
} else if res.Status.Phase == "" && len(res.Status.Conditions) > 0 { } else if res.Status.Phase == "" && len(res.Status.Conditions) > 0 {

View File

@@ -71,18 +71,6 @@ function popUpUpgrade(elm, ns, name, verCur, lastRev) {
$("#upgradeModal .rel-ns").prop("disabled", false).val("") $("#upgradeModal .rel-ns").prop("disabled", false).val("")
} }
$.getJSON("/api/kube/namespaces").fail(function (xhr) {
reportError("Failed to get namespaces", xhr)
}).done(function(res) {
const ns = res.items.map(i => i.metadata.name)
$.each(ns, function(i, item) {
$("#upgradeModal #ns-datalist").append($("<option>", {
value: item,
text: item
}))
})
})
$.getJSON("/api/helm/repo/search?name=" + elm.name).fail(function (xhr) { $.getJSON("/api/helm/repo/search?name=" + elm.name).fail(function (xhr) {
reportError("Failed to find chart in repo", xhr) reportError("Failed to find chart in repo", xhr)
}).done(function (vers) { }).done(function (vers) {

View File

@@ -14,6 +14,18 @@ $(function () {
initView(); // can only do it after loading cluster list initView(); // can only do it after loading cluster list
}) })
$.getJSON("/api/kube/namespaces").fail(function (xhr) {
reportError("Failed to get namespaces", xhr)
}).done(function(res) {
const ns = res.items.map(i => i.metadata.name)
$.each(ns, function(i, item) {
$("#upgradeModal #ns-datalist").append($("<option>", {
value: item,
text: item
}))
})
})
$.getJSON("/api/scanners").fail(function (xhr) { $.getJSON("/api/scanners").fail(function (xhr) {
reportError("Failed to get list of scanners", xhr) reportError("Failed to get list of scanners", xhr)
}).done(function (data) { }).done(function (data) {
@@ -137,7 +149,7 @@ function getCleanClusterName(rawClusterName) {
const region = clusterSplit.at(-3) const region = clusterSplit.at(-3)
return region + "/" + clusterName + ' [AWS]' return region + "/" + clusterName + ' [AWS]'
} }
if (rawClusterName.indexOf('gke') === 0) { if (rawClusterName.indexOf('gke') === 0) {
// GKE cluster // GKE cluster
return rawClusterName.split('_').at(-2) + '/' + rawClusterName.split('_').at(-1) + ' [GKE]' return rawClusterName.split('_').at(-2) + '/' + rawClusterName.split('_').at(-1) + ' [GKE]'

View File

@@ -521,3 +521,11 @@ func GetDiff(text1 string, text2 string, name1 string, name2 string) string {
log.Debugf("The diff is: %s", diff) log.Debugf("The diff is: %s", diff)
return diff return diff
} }
type NamespaceElement struct {
Items []struct {
Metadata struct {
Name string `json:"name"`
} `json:"metadata"`
} `json:"items"`
}

View File

@@ -43,11 +43,3 @@ type RepositoryElement struct {
Name string `json:"name"` Name string `json:"name"`
URL string `json:"url"` URL string `json:"url"`
} }
type NamespaceElement struct {
Items []struct {
Metadata struct {
Name string `json:"name"`
} `json:"metadata"`
} `json:"items"`
}