1
0
mirror of https://github.com/rancher/steve.git synced 2025-08-18 22:28:35 +00:00
steve/pkg/resources/virtual/virtual.go
Silvio Moioli dd27bd0c8d
[v2.9] Virtual Resource filters (#288)
Adds logic which adds virtual fields resources. This allows these fields
to be sorted/filtered on when the SQL cache is enabled. Id and
metadata.state.name were added as the first two fields.

Co-authored-by: Michael Bolot <michael.bolot@suse.com>
2024-10-02 14:59:54 +02:00

29 lines
964 B
Go

// Package virtual provides functions/resources to define virtual fields (fields which don't exist in k8s
// but should be visible in the API) on resources
package virtual
import (
"github.com/rancher/steve/pkg/resources/virtual/common"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/tools/cache"
)
// TransformBuilder builds transform functions for specified GVKs through GetTransformFunc
type TransformBuilder struct {
defaultFields *common.DefaultFields
}
// NewTransformBuilder returns a TransformBuilder using the given summary cache
func NewTransformBuilder(cache common.SummaryCache) *TransformBuilder {
return &TransformBuilder{
&common.DefaultFields{
Cache: cache,
},
}
}
// GetTransformFunc retrieves a TransformFunc for a given GVK. Currently only returns a transformFunc for defaultFields
func (t *TransformBuilder) GetTransformFunc(_ schema.GroupVersionKind) cache.TransformFunc {
return t.defaultFields.GetTransform()
}