Scopes: Add DashboardTitle to scopedashboardbinding (#88609)

scopes: add title to scopedashboardbinding

Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
Carl Bergquist 2024-06-04 09:36:03 +02:00 committed by GitHub
parent 3af72bdeee
commit c99fe4f970
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 22 additions and 44 deletions

View File

@ -19,9 +19,7 @@ type Scope struct {
type ScopeSpec struct { type ScopeSpec struct {
Title string `json:"title"` Title string `json:"title"`
Type string `json:"type"`
Description string `json:"description"` Description string `json:"description"`
Category string `json:"category"`
// +listType=atomic // +listType=atomic
Filters []ScopeFilter `json:"filters"` Filters []ScopeFilter `json:"filters"`
@ -62,8 +60,10 @@ type ScopeDashboardBinding struct {
} }
type ScopeDashboardBindingSpec struct { type ScopeDashboardBindingSpec struct {
Dashboard string `json:"dashboard"` Dashboard string `json:"dashboard"`
Scope string `json:"scope"` DashboardTitle string `json:"dashboardTitle"`
Scope string `json:"scope"`
} }
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View File

@ -171,6 +171,13 @@ func schema_pkg_apis_scope_v0alpha1_ScopeDashboardBindingSpec(ref common.Referen
Format: "", Format: "",
}, },
}, },
"dashboardTitle": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"scope": { "scope": {
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Default: "", Default: "",
@ -179,7 +186,7 @@ func schema_pkg_apis_scope_v0alpha1_ScopeDashboardBindingSpec(ref common.Referen
}, },
}, },
}, },
Required: []string{"dashboard", "scope"}, Required: []string{"dashboard", "dashboardTitle", "scope"},
}, },
}, },
} }
@ -424,13 +431,6 @@ func schema_pkg_apis_scope_v0alpha1_ScopeSpec(ref common.ReferenceCallback) comm
Format: "", Format: "",
}, },
}, },
"type": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"description": { "description": {
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Default: "", Default: "",
@ -438,13 +438,6 @@ func schema_pkg_apis_scope_v0alpha1_ScopeSpec(ref common.ReferenceCallback) comm
Format: "", Format: "",
}, },
}, },
"category": {
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
"filters": { "filters": {
VendorExtensible: spec.VendorExtensible{ VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{ Extensions: spec.Extensions{
@ -464,7 +457,7 @@ func schema_pkg_apis_scope_v0alpha1_ScopeSpec(ref common.ReferenceCallback) comm
}, },
}, },
}, },
Required: []string{"title", "type", "description", "category", "filters"}, Required: []string{"title", "description", "filters"},
}, },
}, },
Dependencies: []string{ Dependencies: []string{

View File

@ -162,8 +162,7 @@ func Matcher(label labels.Selector, field fields.Selector) apistore.SelectionPre
func SelectableScopeFields(obj *scope.Scope) fields.Set { func SelectableScopeFields(obj *scope.Scope) fields.Set {
return generic.MergeFieldsSets(generic.ObjectMetaFieldsSet(&obj.ObjectMeta, false), fields.Set{ return generic.MergeFieldsSets(generic.ObjectMetaFieldsSet(&obj.ObjectMeta, false), fields.Set{
"spec.type": obj.Spec.Type, "spec.title": obj.Spec.Title,
"spec.category": obj.Spec.Category,
}) })
} }

View File

@ -141,7 +141,7 @@ func TestIntegrationScopes(t *testing.T) {
// Field Selector test // Field Selector test
found, err := scopeClient.Resource.List(ctx, metav1.ListOptions{ found, err := scopeClient.Resource.List(ctx, metav1.ListOptions{
FieldSelector: "spec.category=fun", FieldSelector: "spec.title=foo-scope",
}) })
require.NoError(t, err) require.NoError(t, err)
require.Len(t, found.Items, 1) require.Len(t, found.Items, 1)

View File

@ -3,10 +3,8 @@ kind: Scope
metadata: metadata:
name: example name: example
spec: spec:
title: Example scope title: bar-scope
description: Longer description for a scope description: Longer description for a scope
category: should this be an enum or an external reference?
type: should this be an enum or an external reference?
filters: filters:
- key: aaa - key: aaa
operator: equals operator: equals

View File

@ -3,10 +3,8 @@ kind: Scope
metadata: metadata:
name: example2 name: example2
spec: spec:
title: Example scope 2 title: foo-scope
description: Longer description for a scope description: Longer description for a scope
category: fun
type: should this be an enum or an external reference?
filters: filters:
- key: aaa - key: aaa
operator: equals operator: equals

View File

@ -8,7 +8,6 @@
"name": "slothClusterNorth" "name": "slothClusterNorth"
}, },
"spec": { "spec": {
"category": "clusters",
"description": "slothClusterNorth", "description": "slothClusterNorth",
"filters": [ "filters": [
{ {
@ -17,8 +16,7 @@
"value": "slothClusterNorth" "value": "slothClusterNorth"
} }
], ],
"title": "slothClusterNorth", "title": "slothClusterNorth"
"type": "cluster"
} }
}, },
{ {
@ -28,7 +26,6 @@
"name": "slothClusterSouth" "name": "slothClusterSouth"
}, },
"spec": { "spec": {
"category": "clusters",
"description": "slothClusterSouth", "description": "slothClusterSouth",
"filters": [ "filters": [
{ {
@ -37,8 +34,7 @@
"value": "slothClusterSouth" "value": "slothClusterSouth"
} }
], ],
"title": "slothClusterSouth", "title": "slothClusterSouth"
"type": "cluster"
} }
}, },
{ {
@ -48,7 +44,6 @@
"name": "slothPictureFactory" "name": "slothPictureFactory"
}, },
"spec": { "spec": {
"category": "apps",
"description": "slothPictureFactory", "description": "slothPictureFactory",
"filters": [ "filters": [
{ {
@ -57,8 +52,7 @@
"value": "slothPictureFactory" "value": "slothPictureFactory"
} }
], ],
"title": "slothPictureFactory", "title": "slothPictureFactory"
"type": "app"
} }
}, },
{ {
@ -68,7 +62,6 @@
"name": "slothVoteTracker" "name": "slothVoteTracker"
}, },
"spec": { "spec": {
"category": "apps",
"description": "slothVoteTracker", "description": "slothVoteTracker",
"filters": [ "filters": [
{ {
@ -77,8 +70,7 @@
"value": "slothVoteTracker" "value": "slothVoteTracker"
} }
], ],
"title": "slothVoteTracker", "title": "slothVoteTracker"
"type": "app"
} }
}, },
{ {
@ -88,7 +80,6 @@
"name": "indexHelperCluster" "name": "indexHelperCluster"
}, },
"spec": { "spec": {
"category": "indexHelpers",
"description": "redundant label filter but makes queries faster", "description": "redundant label filter but makes queries faster",
"filters": [ "filters": [
{ {
@ -97,8 +88,7 @@
"value": "cluster" "value": "cluster"
} }
], ],
"title": "Cluster Index Helper", "title": "Cluster Index Helper"
"type": "indexHelper"
} }
} }
] ]