Schemas: minor updates from the k8s branch (#71688)

Co-authored-by: sam boyer <sdboyer@grafana.com>
This commit is contained in:
Ryan McKinley
2023-07-21 19:17:11 +03:00
committed by GitHub
co-authored by sam boyer
parent 6c1346cbc1
commit 10ea92fa09
24 changed files with 81 additions and 28 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ func (ag *ResourceGoTypesJenny) Generate(kind kindsys.Kind) (*codejen.File, erro
if err := tmpls.Lookup("core_resource.tmpl").Execute(buf, tvars_resource{
PackageName: mname,
KindName: kind.Props().Common().Name,
Version: sch.Version().String(),
Version: strings.Replace(sfg.Schema.Version().String(), ".", "-", -1),
SubresourceNames: subr,
}); err != nil {
return nil, fmt.Errorf("failed executing core resource template: %w", err)
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "AccessPolicy",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Dashboard",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -740,7 +740,7 @@ type Spec struct {
// Unique numeric identifier for the dashboard.
// `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
Id *int64 `json:"id,omitempty"`
Id *int64 `json:"id"`
// Links with references to other dashboards or external websites.
Links []Link `json:"links,omitempty"`
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Folder",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "LibraryPanel",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Playlist",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Preferences",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
@@ -9,6 +9,13 @@
package preferences
// CookiePreferences defines model for CookiePreferences.
type CookiePreferences struct {
Analytics map[string]any `json:"analytics,omitempty"`
Functional map[string]any `json:"functional,omitempty"`
Performance map[string]any `json:"performance,omitempty"`
}
// QueryHistoryPreference defines model for QueryHistoryPreference.
type QueryHistoryPreference struct {
// HomeTab one of: '' | 'query' | 'starred';
@@ -17,6 +24,8 @@ type QueryHistoryPreference struct {
// Spec defines model for Spec.
type Spec struct {
CookiePreferences *CookiePreferences `json:"cookiePreferences,omitempty"`
// UID for the home dashboard
HomeDashboardUID *string `json:"homeDashboardUID,omitempty"`
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "PublicDashboard",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Role",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "RoleBinding",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status]
func NewK8sResource(name string, s *Spec) K8sResource {
return K8sResource{
Kind: "Team",
APIVersion: "v0.0-alpha",
APIVersion: "v0-0-alpha",
Metadata: kinds.GrafanaResourceMetadata{
Name: name,
Annotations: make(map[string]string),
+1 -1
View File
@@ -114,7 +114,7 @@ func TestResourceConversion(t *testing.T) {
require.NoError(t, err)
fmt.Printf("%s", string(out))
require.JSONEq(t, `{
"apiVersion": "v0.0-alpha",
"apiVersion": "v0-0-alpha",
"kind": "Dashboard",
"metadata": {
"name": "TheUID",
@@ -39,7 +39,7 @@ func TestLibaryPanelConversion(t *testing.T) {
require.NoError(t, err)
fmt.Printf("%s", string(out))
require.JSONEq(t, `{
"apiVersion": "v0.0-alpha",
"apiVersion": "v0-0-alpha",
"kind": "LibraryPanel",
"metadata": {
"name": "TheUID",
+1 -1
View File
@@ -32,7 +32,7 @@ func TestPlaylistConversion(t *testing.T) {
require.NoError(t, err)
fmt.Printf("%s", string(out))
require.JSONEq(t, `{
"apiVersion": "v0.0-alpha",
"apiVersion": "v0-0-alpha",
"kind": "Playlist",
"metadata": {
"name": "abc",
+1 -1
View File
@@ -28,7 +28,7 @@ func TestTeamConversion(t *testing.T) {
require.NoError(t, err)
fmt.Printf("%s", string(out))
require.JSONEq(t, `{
"apiVersion": "v0.0-alpha",
"apiVersion": "v0-0-alpha",
"kind": "Team",
"metadata": {
"name": "abc",