/
githubmirror
/
grafana
Обзор
Документация
Войти
/
githubmirror
/
grafana
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
pkg/codegen/tmpl/core_resource.tmpl
34 строки
946 B
Selene
Kinds: Generate k8 resources without use kindys/thema (#83310)
26 фев 2024, 12:18
Не верифицирован
26 фев 2024, 12:18
dea0a0f
Код
Авторство
О чём код?
package {{ .PackageName }} import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "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{ TypeMeta: v1.TypeMeta{ Kind: "{{ .KindName }}", APIVersion: "v{{ .Version }}-alpha", }, ObjectMeta: v1.ObjectMeta{ Name: name, 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) type Resource struct { Metadata Metadata `json:"metadata"` Spec Spec `json:"spec"` Status Status `json:"status"` }