1
0
mirror of https://github.com/rancher/steve.git synced 2025-07-05 11:06:37 +00:00
steve/pkg/resources/virtual/virtual.go
Michael Bolot 1149920168 Adding virtual fields
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.
2024-08-28 12:17:53 -05: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()
}