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 09:17:11 -07:00 committed by GitHub
parent 6c1346cbc1
commit 10ea92fa09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 81 additions and 28 deletions

View File

@ -79,7 +79,7 @@ extraFields is reserved for any fields that are pulled from the API server metad
| `description` | string | No | | Description of dashboard. |
| `fiscalYearStartMonth` | integer | No | `0` | The month that the fiscal year starts on. 0 = January, 11 = December<br/>Constraint: `>=0 & <12`. |
| `gnetId` | string | No | | ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal |
| `id` | integer | No | | Unique numeric identifier for the dashboard.<br/>`id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. |
| `id` | integer or null | No | | Unique numeric identifier for the dashboard.<br/>`id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. |
| `links` | [DashboardLink](#dashboardlink)[] | No | | Links with references to other dashboards or external websites. |
| `liveNow` | boolean | No | | When set to true, the dashboard will redraw panels at an interval matching the pixel width.<br/>This will keep data "moving left" regardless of the query refresh rate. This setting helps<br/>avoid dashboards presenting stale live data |
| `panels` | [object](#panels)[] | No | | List of dashboard panels |

View File

@ -69,14 +69,38 @@ extraFields is reserved for any fields that are pulled from the API server metad
### Spec
| Property | Type | Required | Default | Description |
|--------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------|
| `homeDashboardUID` | string | No | | UID for the home dashboard |
| `language` | string | No | | Selected language (beta) |
| `queryHistory` | [QueryHistoryPreference](#queryhistorypreference) | No | | |
| `theme` | string | No | | light, dark, empty is default |
| `timezone` | string | No | | The timezone selection<br/>TODO: this should use the timezone defined in common |
| `weekStart` | string | No | | day of the week (sunday, monday, etc) |
| Property | Type | Required | Default | Description |
|---------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------|
| `cookiePreferences` | [CookiePreferences](#cookiepreferences) | No | | |
| `homeDashboardUID` | string | No | | UID for the home dashboard |
| `language` | string | No | | Selected language (beta) |
| `queryHistory` | [QueryHistoryPreference](#queryhistorypreference) | No | | |
| `theme` | string | No | | light, dark, empty is default |
| `timezone` | string | No | | The timezone selection<br/>TODO: this should use the timezone defined in common |
| `weekStart` | string | No | | day of the week (sunday, monday, etc) |
### CookiePreferences
| Property | Type | Required | Default | Description |
|---------------|------------------------|----------|---------|-------------|
| `analytics` | [object](#analytics) | No | | |
| `functional` | [object](#functional) | No | | |
| `performance` | [object](#performance) | No | | |
### Analytics
| Property | Type | Required | Default | Description |
|----------|------|----------|---------|-------------|
### Functional
| Property | Type | Required | Default | Description |
|----------|------|----------|---------|-------------|
### Performance
| Property | Type | Required | Default | Description |
|----------|------|----------|---------|-------------|
### QueryHistoryPreference

View File

@ -17,7 +17,7 @@ lineage: schemas: [{
spec: {
// 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
id?: int64 | null // TODO eliminate this null option
// Unique dashboard identifier that can be generated by anyone. string (8-40)
uid?: string

View File

@ -27,11 +27,20 @@ lineage: schemas: [{
// Explore query history preferences
queryHistory?: #QueryHistoryPreference
// Cookie preferences
cookiePreferences?: #CookiePreferences
} @cuetsy(kind="interface")
#QueryHistoryPreference: {
// one of: '' | 'query' | 'starred';
homeTab?: string
} @cuetsy(kind="interface")
#CookiePreferences: {
analytics?: {}
performance?: {}
functional?: {}
} @cuetsy(kind="interface")
}
}]

View File

@ -137,7 +137,8 @@ export { defaultPlaylist } from './raw/playlist/x/playlist_types.gen';
// Raw generated types from Preferences kind.
export type {
Preferences,
QueryHistoryPreference
QueryHistoryPreference,
CookiePreferences
} from './raw/preferences/x/preferences_types.gen';
// Raw generated types from PublicDashboard kind.

View File

@ -1021,7 +1021,7 @@ export interface Dashboard {
* 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?: number;
id?: (number | null); // TODO eliminate this null option
/**
* Links with references to other dashboards or external websites.
*/

View File

@ -15,7 +15,17 @@ export interface QueryHistoryPreference {
homeTab?: string;
}
export interface CookiePreferences {
analytics?: Record<string, unknown>;
functional?: Record<string, unknown>;
performance?: Record<string, unknown>;
}
export interface Preferences {
/**
* Cookie preferences
*/
cookiePreferences?: CookiePreferences;
/**
* UID for the home dashboard
*/

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)

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),

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),

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"`

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),

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),

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),

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),

View File

@ -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"`

View File

@ -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),

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),

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),

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),

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",

View File

@ -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",

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",

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",