From 1328a32a31a773c11da47d7887ef83ca9db64cac Mon Sep 17 00:00:00 2001 From: Selene Date: Tue, 21 Mar 2023 10:42:19 +0100 Subject: [PATCH] Chore: Fix times in schemas (#64906) * Fix times in schemas * Fix frontend lints --- .../kinds/core/serviceaccount/schema-reference.md | 4 ++-- .../developers/kinds/core/team/schema-reference.md | 4 ++-- kinds/librarypanel/librarypanel_kind.cue | 9 ++++++--- kinds/serviceaccount/serviceaccount_kind.cue | 6 ++++-- kinds/team/team_kind.cue | 6 ++++-- .../src/raw/serviceaccount/x/serviceaccount_types.gen.ts | 4 ++-- packages/grafana-schema/src/raw/team/x/team_types.gen.ts | 4 ++-- pkg/kinds/librarypanel/crd/librarypanel.crd.yml | 2 ++ pkg/kinds/librarypanel/librarypanel_types_gen.go | 8 ++++++-- pkg/kinds/serviceaccount/crd/serviceaccount.crd.yml | 8 ++++---- pkg/kinds/serviceaccount/serviceaccount_types_gen.go | 8 ++++++-- pkg/kinds/team/crd/team.crd.yml | 8 ++++---- pkg/kinds/team/team_types_gen.go | 8 ++++++-- pkg/kindsysreport/codegen/report.json | 6 +++--- public/app/features/teams/__mocks__/teamMocks.ts | 4 ++-- public/app/features/teams/state/navModel.ts | 4 ++-- 16 files changed, 57 insertions(+), 36 deletions(-) diff --git a/docs/sources/developers/kinds/core/serviceaccount/schema-reference.md b/docs/sources/developers/kinds/core/serviceaccount/schema-reference.md index 3cb87a2590e..5b6fde83b36 100644 --- a/docs/sources/developers/kinds/core/serviceaccount/schema-reference.md +++ b/docs/sources/developers/kinds/core/serviceaccount/schema-reference.md @@ -24,8 +24,8 @@ system account | `role` | string | **Yes** | OrgRole is a Grafana Organization Role which can be 'Viewer', 'Editor', 'Admin'.
Possible values are: `Admin`, `Editor`, `Viewer`. | | `tokens` | integer | **Yes** | Tokens is the number of active tokens for the service account.
Tokens are used to authenticate the service account against Grafana. | | `accessControl` | map[string]boolean | No | AccessControl metadata associated with a given resource. | -| `created` | integer | No | Created indicates when the service account was created. | +| `created` | string | No | Created indicates when the service account was created. | | `teams` | string[] | No | Teams is a list of teams the service account belongs to. | -| `updated` | integer | No | Updated indicates when the service account was updated. | +| `updated` | string | No | Updated indicates when the service account was updated. | diff --git a/docs/sources/developers/kinds/core/team/schema-reference.md b/docs/sources/developers/kinds/core/team/schema-reference.md index df084c79b81..5de0fdcb3df 100644 --- a/docs/sources/developers/kinds/core/team/schema-reference.md +++ b/docs/sources/developers/kinds/core/team/schema-reference.md @@ -15,12 +15,12 @@ A team is a named grouping of Grafana users to which access control rules may be | Property | Type | Required | Description | |-----------------|--------------------|----------|----------------------------------------------------------| -| `created` | integer | **Yes** | Created indicates when the team was created. | +| `created` | string | **Yes** | Created indicates when the team was created. | | `memberCount` | integer | **Yes** | MemberCount is the number of the team members. | | `name` | string | **Yes** | Name of the team. | | `orgId` | integer | **Yes** | OrgId is the ID of an organisation the team belongs to. | | `permission` | integer | **Yes** | Possible values are: `0`, `1`, `2`, `4`. | -| `updated` | integer | **Yes** | Updated indicates when the team was updated. | +| `updated` | string | **Yes** | Updated indicates when the team was updated. | | `accessControl` | map[string]boolean | No | AccessControl metadata associated with a given resource. | | `avatarUrl` | string | No | AvatarUrl is the team's avatar URL. | | `email` | string | No | Email of the team. | diff --git a/kinds/librarypanel/librarypanel_kind.cue b/kinds/librarypanel/librarypanel_kind.cue index e097dddd5f0..82870b812d3 100644 --- a/kinds/librarypanel/librarypanel_kind.cue +++ b/kinds/librarypanel/librarypanel_kind.cue @@ -1,6 +1,9 @@ package kind -import "strings" +import ( + "strings" + "time" +) name: "LibraryPanel" maturity: "experimental" @@ -52,8 +55,8 @@ lineage: seqs: [ folderUid: string @grafanamaturity(ToMetadata="sys") connectedDashboards: int64 - created: string @grafanamaturity(ToMetadata="sys") // time.Time in golang - updated: string @grafanamaturity(ToMetadata="sys") // time.Time in golang + created: string & time.Time + updated: string & time.Time createdBy: #LibraryElementDTOMetaUser @grafanamaturity(ToMetadata="sys") updatedBy: #LibraryElementDTOMetaUser @grafanamaturity(ToMetadata="sys") diff --git a/kinds/serviceaccount/serviceaccount_kind.cue b/kinds/serviceaccount/serviceaccount_kind.cue index fc49a346611..27f54a17db7 100644 --- a/kinds/serviceaccount/serviceaccount_kind.cue +++ b/kinds/serviceaccount/serviceaccount_kind.cue @@ -1,5 +1,7 @@ package kind +import "time" + name: "ServiceAccount" maturity: "merged" description: "system account" @@ -35,9 +37,9 @@ lineage: seqs: [ // Teams is a list of teams the service account belongs to. teams?: [...string] @grafanamaturity(ToMetadata="sys") // Created indicates when the service account was created. - created?: int64 @grafanamaturity(ToMetadata="sys") + created?: string & time.Time // Updated indicates when the service account was updated. - updated?: int64 @grafanamaturity(ToMetadata="sys") + updated?: string & time.Time // OrgRole is a Grafana Organization Role which can be 'Viewer', 'Editor', 'Admin'. #OrgRole: "Admin" | "Editor" | "Viewer" @cuetsy(kind="type") diff --git a/kinds/team/team_kind.cue b/kinds/team/team_kind.cue index 8146ddc95ca..58d285fa93c 100644 --- a/kinds/team/team_kind.cue +++ b/kinds/team/team_kind.cue @@ -1,5 +1,7 @@ package kind +import "time" + name: "Team" maturity: "merged" description: "A team is a named grouping of Grafana users to which access control rules may be assigned." @@ -26,9 +28,9 @@ lineage: seqs: [ [string]: bool @grafanamaturity(ToMetadata="sys") } // Created indicates when the team was created. - created: int64 @grafanamaturity(ToMetadata="sys") + created: string & time.Time // Updated indicates when the team was updated. - updated: int64 @grafanamaturity(ToMetadata="sys") + updated: string & time.Time #Permission: 0 | 1 | 2 | 4 @cuetsy(kind="enum",memberNames="Member|Viewer|Editor|Admin") }, diff --git a/packages/grafana-schema/src/raw/serviceaccount/x/serviceaccount_types.gen.ts b/packages/grafana-schema/src/raw/serviceaccount/x/serviceaccount_types.gen.ts index a06b06ff31f..d2713bf993d 100644 --- a/packages/grafana-schema/src/raw/serviceaccount/x/serviceaccount_types.gen.ts +++ b/packages/grafana-schema/src/raw/serviceaccount/x/serviceaccount_types.gen.ts @@ -26,7 +26,7 @@ export interface ServiceAccount { /** * Created indicates when the service account was created. */ - created?: number; + created?: string; /** * ID is the unique identifier of the service account in the database. */ @@ -63,7 +63,7 @@ export interface ServiceAccount { /** * Updated indicates when the service account was updated. */ - updated?: number; + updated?: string; } export const defaultServiceAccount: Partial = { diff --git a/packages/grafana-schema/src/raw/team/x/team_types.gen.ts b/packages/grafana-schema/src/raw/team/x/team_types.gen.ts index 736267a269f..3482c0c758c 100644 --- a/packages/grafana-schema/src/raw/team/x/team_types.gen.ts +++ b/packages/grafana-schema/src/raw/team/x/team_types.gen.ts @@ -27,7 +27,7 @@ export interface Team { /** * Created indicates when the team was created. */ - created: number; + created: string; /** * Email of the team. */ @@ -51,5 +51,5 @@ export interface Team { /** * Updated indicates when the team was updated. */ - updated: number; + updated: string; } diff --git a/pkg/kinds/librarypanel/crd/librarypanel.crd.yml b/pkg/kinds/librarypanel/crd/librarypanel.crd.yml index a3a31f0fe21..387b40fc12a 100644 --- a/pkg/kinds/librarypanel/crd/librarypanel.crd.yml +++ b/pkg/kinds/librarypanel/crd/librarypanel.crd.yml @@ -35,6 +35,7 @@ spec: format: int64 type: integer created: + format: date-time type: string createdBy: properties: @@ -55,6 +56,7 @@ spec: folderUid: type: string updated: + format: date-time type: string updatedBy: properties: diff --git a/pkg/kinds/librarypanel/librarypanel_types_gen.go b/pkg/kinds/librarypanel/librarypanel_types_gen.go index b290be51f48..5bc008309d7 100644 --- a/pkg/kinds/librarypanel/librarypanel_types_gen.go +++ b/pkg/kinds/librarypanel/librarypanel_types_gen.go @@ -10,14 +10,18 @@ package librarypanel +import ( + "time" +) + // LibraryElementDTOMeta defines model for LibraryElementDTOMeta. type LibraryElementDTOMeta struct { ConnectedDashboards int64 `json:"connectedDashboards"` - Created string `json:"created"` + Created time.Time `json:"created"` CreatedBy LibraryElementDTOMetaUser `json:"createdBy"` FolderName string `json:"folderName"` FolderUid string `json:"folderUid"` - Updated string `json:"updated"` + Updated time.Time `json:"updated"` UpdatedBy LibraryElementDTOMetaUser `json:"updatedBy"` } diff --git a/pkg/kinds/serviceaccount/crd/serviceaccount.crd.yml b/pkg/kinds/serviceaccount/crd/serviceaccount.crd.yml index c38aad58ab0..31c2131b9e8 100644 --- a/pkg/kinds/serviceaccount/crd/serviceaccount.crd.yml +++ b/pkg/kinds/serviceaccount/crd/serviceaccount.crd.yml @@ -34,8 +34,8 @@ spec: type: string created: description: Created indicates when the service account was created. - format: int64 - type: integer + format: date-time + type: string id: description: ID is the unique identifier of the service account in the database. format: int64 @@ -73,8 +73,8 @@ spec: type: integer updated: description: Updated indicates when the service account was updated. - format: int64 - type: integer + format: date-time + type: string required: - id - orgId diff --git a/pkg/kinds/serviceaccount/serviceaccount_types_gen.go b/pkg/kinds/serviceaccount/serviceaccount_types_gen.go index 4f3ccfbf30f..d4ab2b4157b 100644 --- a/pkg/kinds/serviceaccount/serviceaccount_types_gen.go +++ b/pkg/kinds/serviceaccount/serviceaccount_types_gen.go @@ -10,6 +10,10 @@ package serviceaccount +import ( + "time" +) + // Defines values for OrgRole. const ( OrgRoleAdmin OrgRole = "Admin" @@ -30,7 +34,7 @@ type ServiceAccount struct { AvatarUrl string `json:"avatarUrl"` // Created indicates when the service account was created. - Created *int64 `json:"created,omitempty"` + Created *time.Time `json:"created,omitempty"` // ID is the unique identifier of the service account in the database. Id int64 `json:"id"` @@ -58,5 +62,5 @@ type ServiceAccount struct { Tokens int64 `json:"tokens"` // Updated indicates when the service account was updated. - Updated *int64 `json:"updated,omitempty"` + Updated *time.Time `json:"updated,omitempty"` } diff --git a/pkg/kinds/team/crd/team.crd.yml b/pkg/kinds/team/crd/team.crd.yml index d8d81f4dc7e..de995049e83 100644 --- a/pkg/kinds/team/crd/team.crd.yml +++ b/pkg/kinds/team/crd/team.crd.yml @@ -32,8 +32,8 @@ spec: type: string created: description: Created indicates when the team was created. - format: int64 - type: integer + format: date-time + type: string email: description: Email of the team. type: string @@ -58,8 +58,8 @@ spec: type: integer updated: description: Updated indicates when the team was updated. - format: int64 - type: integer + format: date-time + type: string required: - orgId - name diff --git a/pkg/kinds/team/team_types_gen.go b/pkg/kinds/team/team_types_gen.go index b45d5bcde2e..580a803f6da 100644 --- a/pkg/kinds/team/team_types_gen.go +++ b/pkg/kinds/team/team_types_gen.go @@ -10,6 +10,10 @@ package team +import ( + "time" +) + // Defines values for Permission. const ( PermissionN0 Permission = 0 @@ -30,7 +34,7 @@ type Team struct { AvatarUrl *string `json:"avatarUrl,omitempty"` // Created indicates when the team was created. - Created int64 `json:"created"` + Created time.Time `json:"created"` // Email of the team. Email *string `json:"email,omitempty"` @@ -46,5 +50,5 @@ type Team struct { Permission Permission `json:"permission"` // Updated indicates when the team was updated. - Updated int64 `json:"updated"` + Updated time.Time `json:"updated"` } diff --git a/pkg/kindsysreport/codegen/report.json b/pkg/kindsysreport/codegen/report.json index f900e8cd829..e760dbf9170 100644 --- a/pkg/kindsysreport/codegen/report.json +++ b/pkg/kindsysreport/codegen/report.json @@ -878,7 +878,7 @@ 0 ], "description": "A standalone panel", - "grafanaMaturityCount": 10, + "grafanaMaturityCount": 8, "lineageIsGroup": false, "links": { "docs": "https://grafana.com/docs/grafana/next/developers/kinds/core/librarypanel/schema-reference", @@ -1492,7 +1492,7 @@ 0 ], "description": "system account", - "grafanaMaturityCount": 9, + "grafanaMaturityCount": 7, "lineageIsGroup": false, "links": { "docs": "https://grafana.com/docs/grafana/next/developers/kinds/core/serviceaccount/schema-reference", @@ -1642,7 +1642,7 @@ 0 ], "description": "A team is a named grouping of Grafana users to which access control rules may be assigned.", - "grafanaMaturityCount": 7, + "grafanaMaturityCount": 5, "lineageIsGroup": false, "links": { "docs": "https://grafana.com/docs/grafana/next/developers/kinds/core/team/schema-reference", diff --git a/public/app/features/teams/__mocks__/teamMocks.ts b/public/app/features/teams/__mocks__/teamMocks.ts index 7e80354880d..ccbac6e2eb6 100644 --- a/public/app/features/teams/__mocks__/teamMocks.ts +++ b/public/app/features/teams/__mocks__/teamMocks.ts @@ -18,9 +18,9 @@ export const getMockTeam = (i = 1, overrides = {}): Team => { memberCount: i, permission: TeamPermissionLevel.Member, accessControl: { isEditor: false }, - created: 0, + created: '', orgId: 0, - updated: 0, + updated: '', ...overrides, }; }; diff --git a/public/app/features/teams/state/navModel.ts b/public/app/features/teams/state/navModel.ts index 2ed6e36d895..5c63bb577de 100644 --- a/public/app/features/teams/state/navModel.ts +++ b/public/app/features/teams/state/navModel.ts @@ -14,9 +14,9 @@ const loadingTeam = { memberCount: 0, permission: TeamPermissionLevel.Member, accessControl: { isEditor: false }, - created: 0, + created: '', orgId: 0, - updated: 0, + updated: '', }; export function buildNavModel(team: Team): NavModelItem {