Normalize conditions

This commit is contained in:
Darren Shepherd 2020-09-22 13:46:46 -07:00
parent b26bbc6494
commit 09d79b238b
2 changed files with 13 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/rancher/steve/pkg/stores/proxy"
"github.com/rancher/steve/pkg/summarycache"
"github.com/rancher/wrangler/pkg/data"
"github.com/rancher/wrangler/pkg/summary"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
@ -42,14 +43,16 @@ func formatter(summarycache *summarycache.SummaryCache) types.Formatter {
}
if unstr, ok := resource.APIObject.Object.(*unstructured.Unstructured); ok {
summary, rel := summarycache.SummaryAndRelationship(unstr)
s, rel := summarycache.SummaryAndRelationship(unstr)
data.PutValue(unstr.Object, map[string]interface{}{
"name": summary.State,
"error": summary.Error,
"transitioning": summary.Transitioning,
"message": strings.Join(summary.Message, ":"),
"name": s.State,
"error": s.Error,
"transitioning": s.Transitioning,
"message": strings.Join(s.Message, ":"),
}, "metadata", "state")
data.PutValue(unstr.Object, rel, "metadata", "relationships")
summary.NormalizeConditions(unstr)
}
}
}

View File

@ -10,6 +10,7 @@ import (
"github.com/rancher/apiserver/pkg/types"
"github.com/rancher/steve/pkg/accesscontrol"
"github.com/rancher/steve/pkg/attributes"
"github.com/rancher/steve/pkg/schema/converter"
"github.com/rancher/wrangler/pkg/name"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/runtime/schema"
@ -218,6 +219,10 @@ func (c *Collection) AddTemplate(templates ...Template) {
for i, template := range templates {
if template.Kind != "" {
c.templates[template.Group+"/"+template.Kind] = &templates[i]
c.templates[converter.GVKToSchemaID(schema.GroupVersionKind{
Group: template.Group,
Kind: template.Kind,
})] = &templates[i]
}
if template.ID != "" {
c.templates[template.ID] = &templates[i]