APIServer: Make TableConverter part of ResourceInfo (#91520)

This commit is contained in:
Ryan McKinley
2024-08-05 15:38:12 +03:00
committed by GitHub
parent f885cc7d9c
commit a223c46506
28 changed files with 479 additions and 506 deletions
+2 -20
View File
@@ -12,7 +12,6 @@ import (
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
"github.com/grafana/grafana/pkg/apis/featuretoggle/v0alpha1"
gapiutil "github.com/grafana/grafana/pkg/services/apiserver/utils"
"github.com/grafana/grafana/pkg/services/featuremgmt"
)
@@ -36,25 +35,8 @@ type featuresStorage struct {
func NewFeaturesStorage() *featuresStorage {
resourceInfo := v0alpha1.FeatureResourceInfo
return &featuresStorage{
resource: &resourceInfo,
tableConverter: gapiutil.NewTableConverter(
resourceInfo.GroupResource(),
[]metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name"},
{Name: "Stage", Type: "string", Format: "string", Description: "Where is the flag in the dev cycle"},
{Name: "Owner", Type: "string", Format: "string", Description: "Which team owns the feature"},
},
func(obj any) ([]interface{}, error) {
r, ok := obj.(*v0alpha1.Feature)
if ok {
return []interface{}{
r.Name,
r.Spec.Stage,
r.Spec.Owner,
}, nil
}
return nil, fmt.Errorf("expected resource or info")
}),
resource: &resourceInfo,
tableConverter: resourceInfo.TableConverter(),
}
}