2019-08-14 18:08:34 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2019-09-11 21:05:00 +00:00
|
|
|
"github.com/rancher/steve/pkg/attributes"
|
2020-01-31 05:37:59 +00:00
|
|
|
"github.com/rancher/steve/pkg/schema/table"
|
|
|
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
|
|
|
"github.com/rancher/wrangler/pkg/schemas"
|
|
|
|
"github.com/rancher/wrangler/pkg/schemas/mappers"
|
2019-08-14 18:08:34 +00:00
|
|
|
)
|
|
|
|
|
2019-09-09 21:28:55 +00:00
|
|
|
var (
|
|
|
|
NameColumn = table.Column{
|
|
|
|
Name: "Name",
|
|
|
|
Field: "metadata.name",
|
|
|
|
Type: "string",
|
|
|
|
Format: "name",
|
|
|
|
}
|
|
|
|
CreatedColumn = table.Column{
|
|
|
|
Name: "Created",
|
|
|
|
Field: "metadata.creationTimestamp",
|
|
|
|
Type: "string",
|
|
|
|
Format: "date",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-08-14 18:08:34 +00:00
|
|
|
type DefaultColumns struct {
|
2020-01-31 05:37:59 +00:00
|
|
|
mappers.EmptyMapper
|
2019-08-14 18:08:34 +00:00
|
|
|
}
|
|
|
|
|
2020-01-31 05:37:59 +00:00
|
|
|
func (d *DefaultColumns) ModifySchema(schema *schemas.Schema, schemas *schemas.Schemas) error {
|
|
|
|
as := &types.APISchema{
|
|
|
|
Schema: schema,
|
|
|
|
}
|
|
|
|
if attributes.Columns(as) == nil {
|
|
|
|
attributes.SetColumns(as, []table.Column{
|
2019-09-09 21:28:55 +00:00
|
|
|
NameColumn,
|
|
|
|
CreatedColumn,
|
2019-08-14 18:08:34 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|