mirror of
https://github.com/rancher/steve.git
synced 2025-09-16 07:18:28 +00:00
[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>
This commit is contained in:
28
pkg/resources/virtual/virtual.go
Normal file
28
pkg/resources/virtual/virtual.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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()
|
||||
}
|
Reference in New Issue
Block a user