mirror of
https://github.com/niusmallnan/steve.git
synced 2025-09-17 15:30:19 +00:00
Add state fields to metadata
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/rancher/steve/pkg/accesscontrol"
|
"github.com/rancher/steve/pkg/accesscontrol"
|
||||||
"github.com/rancher/steve/pkg/schema"
|
"github.com/rancher/steve/pkg/schema"
|
||||||
"github.com/rancher/steve/pkg/schemaserver/types"
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
||||||
"github.com/rancher/steve/pkg/server/store/proxy"
|
"github.com/rancher/steve/pkg/server/store/proxy"
|
||||||
|
"github.com/rancher/wrangler/pkg/data"
|
||||||
|
"github.com/rancher/wrangler/pkg/summary"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DefaultTemplate(clientGetter proxy.ClientGetter, asl accesscontrol.AccessSetLookup) schema.Template {
|
func DefaultTemplate(clientGetter proxy.ClientGetter, asl accesscontrol.AccessSetLookup) schema.Template {
|
||||||
@@ -32,4 +37,14 @@ func Formatter(request *types.APIRequest, resource *types.RawResource) {
|
|||||||
if _, ok := resource.Links["update"]; !ok {
|
if _, ok := resource.Links["update"]; !ok {
|
||||||
resource.Links["update"] = u
|
resource.Links["update"] = u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if unstr, ok := resource.APIObject.Object.(*unstructured.Unstructured); ok {
|
||||||
|
summary := summary.Summarize(unstr)
|
||||||
|
data.PutValue(unstr.Object, map[string]interface{}{
|
||||||
|
"name": summary.State,
|
||||||
|
"error": summary.Error,
|
||||||
|
"transitioning": summary.Transitioning,
|
||||||
|
"message": strings.Join(summary.Message, ":"),
|
||||||
|
}, "metadata", "state")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user