2023-04-27 15:32:38 -05:00
|
|
|
package {{ .PackageName }}
|
|
|
|
|
2023-05-24 11:13:44 -05:00
|
|
|
import (
|
2024-01-12 15:18:14 -06:00
|
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
|
2023-05-24 11:13:44 -05:00
|
|
|
"github.com/grafana/grafana/pkg/kinds"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Resource is the kubernetes style representation of {{ .KindName }}. (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{
|
2024-01-12 15:18:14 -06:00
|
|
|
TypeMeta: v1.TypeMeta{
|
|
|
|
Kind: "{{ .KindName }}",
|
|
|
|
APIVersion: "v{{ .Version }}-alpha",
|
|
|
|
},
|
|
|
|
ObjectMeta: v1.ObjectMeta{
|
|
|
|
Name: name,
|
2023-05-24 11:13:44 -05:00
|
|
|
Annotations: make(map[string]string),
|
|
|
|
Labels: make(map[string]string),
|
|
|
|
},
|
|
|
|
Spec: s,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resource is the wire representation of {{ .KindName }}.
|
|
|
|
// It currently will soon be merged into the k8s flavor (TODO be better)
|
2023-04-27 15:32:38 -05:00
|
|
|
type Resource struct {
|
|
|
|
{{- range .SubresourceNames }}
|
|
|
|
{{ . }} {{ . }} `json:"{{ . | ToLower }}"`{{end}}
|
|
|
|
}
|