Set pod status to state

This commit is contained in:
Darren Shepherd 2020-08-03 19:52:04 -07:00
parent afb90310a2
commit a528c500cf
2 changed files with 17 additions and 4 deletions

View File

@ -1,7 +1,8 @@
package helm
package formatters
import (
"github.com/rancher/apiserver/pkg/types"
"github.com/rancher/norman/types/convert"
)
func DropHelmData(request *types.APIRequest, resource *types.RawResource) {
@ -13,3 +14,11 @@ func DropHelmData(request *types.APIRequest, resource *types.RawResource) {
}
}
}
func Pod(request *types.APIRequest, resource *types.RawResource) {
data := resource.APIObject.Data()
fields := data.StringSlice("metadata", "fields")
if len(fields) > 2 {
data.SetNested(convert.LowerTitle(fields[2]), "metadata", "state", "name")
}
}

View File

@ -14,7 +14,7 @@ import (
"github.com/rancher/steve/pkg/resources/apigroups"
"github.com/rancher/steve/pkg/resources/common"
"github.com/rancher/steve/pkg/resources/counts"
"github.com/rancher/steve/pkg/resources/helm"
"github.com/rancher/steve/pkg/resources/formatters"
"github.com/rancher/steve/pkg/resources/userpreferences"
"github.com/rancher/steve/pkg/schema"
"github.com/rancher/steve/pkg/stores/proxy"
@ -38,11 +38,15 @@ func DefaultSchemaTemplates(cf *client.Factory,
apigroups.Template(discovery),
{
ID: "configmap",
Formatter: helm.DropHelmData,
Formatter: formatters.DropHelmData,
},
{
ID: "secret",
Formatter: helm.DropHelmData,
Formatter: formatters.DropHelmData,
},
{
ID: "pod",
Formatter: formatters.Pod,
},
}
}