Kinds: Use apimachinery ObjectMeta for metadata (#68668)

This commit is contained in:
Ryan McKinley
2023-05-24 09:13:44 -07:00
committed by GitHub
parent f91c1b9897
commit c66d5721f7
22 changed files with 695 additions and 11 deletions
+24 -1
View File
@@ -9,7 +9,30 @@
package dashboard
// Resource is the wire representation of Dashboard. (TODO be better)
import (
"github.com/grafana/grafana/pkg/kinds"
)
// Resource is the kubernetes style representation of Dashboard. (TODO be better)
type K8sResource = kinds.GrafanaResource[Spec, Status]
// NewResource creates a new instance of the resource with a given name (UID)
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Dashboard",
APIVersion: "v0.0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
Labels: make(map[string]string),
},
Spec: s,
}
}
// Resource is the wire representation of Dashboard.
// It currently will soon be merged into the k8s flavor (TODO be better)
type Resource struct {
Metadata Metadata `json:"metadata"`
Spec Spec `json:"spec"`