K8s: Move GrafanaMetaAccessor into grafana-apiserver and remove usage of kinds metadata (#79602)

* move GrafanaMetaAccessor into pkg/apis, add support for Spec.Title & Spec.Name

* K8s: Move GrafanaMetaAccessor (PR into another) (#79728)

* access titles

* remove title

* remove title

* remove kinds metadata accessor

* remove kinds metadata accessor

* fixes

* error handling

* fix tests

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Dan Cech
2024-01-12 16:18:14 -05:00
committed by GitHub
co-authored by Ryan McKinley
parent da894994d4
commit d76defe517
25 changed files with 621 additions and 645 deletions
+8 -4
View File
@@ -1,6 +1,8 @@
package {{ .PackageName }}
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/grafana/grafana/pkg/kinds"
)
@@ -10,10 +12,12 @@ 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: "{{ .KindName }}",
APIVersion: "v{{ .Version }}-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
TypeMeta: v1.TypeMeta{
Kind: "{{ .KindName }}",
APIVersion: "v{{ .Version }}-alpha",
},
ObjectMeta: v1.ObjectMeta{
Name: name,
Annotations: make(map[string]string),
Labels: make(map[string]string),
},