mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 11:48:04 +00:00
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -133,8 +134,19 @@ func (h *HelmHandler) Resources(c *gin.Context) {
|
|||||||
|
|
||||||
res, err := objects.ParseManifests(rel.Orig.Manifest)
|
res, err := objects.ParseManifests(rel.Orig.Manifest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
res = append(res, &v1.Carp{
|
||||||
return
|
TypeMeta: metav1.TypeMeta{Kind: "ManifestParseError"},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: err.Error(),
|
||||||
|
},
|
||||||
|
Spec: v1.CarpSpec{},
|
||||||
|
Status: v1.CarpStatus{
|
||||||
|
Phase: "BrokenManifest",
|
||||||
|
Message: err.Error(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
//_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
|
//return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Query("health") != "" { // we need to query k8s for health status
|
if c.Query("health") != "" { // we need to query k8s for health status
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"helm.sh/helm/v3/pkg/release"
|
"helm.sh/helm/v3/pkg/release"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
//"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DataLayer struct {
|
type DataLayer struct {
|
||||||
@@ -113,20 +114,20 @@ func ParseManifests(out string) ([]*v1.Carp, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errorx.Decorate(err, "failed to parse manifest document #%d", len(res)+1)
|
return res, errorx.Decorate(err, "failed to parse manifest document #%d", len(res)+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// k8s libs uses only JSON tags defined, say hello to https://github.com/go-yaml/yaml/issues/424
|
// k8s libs uses only JSON tags defined, say hello to https://github.com/go-yaml/yaml/issues/424
|
||||||
// we can juggle it
|
// we can juggle it
|
||||||
jsoned, err := json.Marshal(tmp)
|
jsoned, err := json.Marshal(tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var doc v1.Carp
|
var doc v1.Carp
|
||||||
err = json.Unmarshal(jsoned, &doc)
|
err = json.Unmarshal(jsoned, &doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if doc.Kind == "" {
|
if doc.Kind == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user