From fe8a05c648bdda7e41578ea9d497b9ebfc80dfca Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Mon, 1 Jul 2024 08:12:28 -0700 Subject: [PATCH] minor lint fixes --- .../apis/dashboard/legacy/sql_dashboards.go | 2 +- pkg/services/apiserver/options/storage.go | 2 +- pkg/tests/apis/dashboard/dashboards_test.go | 104 +++++++++--------- .../settings/VersionsEditView.tsx | 2 +- .../settings/version-history/HistorySrv.ts | 13 +-- .../VersionsSettings.test.tsx | 8 +- 6 files changed, 66 insertions(+), 65 deletions(-) diff --git a/pkg/registry/apis/dashboard/legacy/sql_dashboards.go b/pkg/registry/apis/dashboard/legacy/sql_dashboards.go index 35410bbb5af..e3ed6cda116 100644 --- a/pkg/registry/apis/dashboard/legacy/sql_dashboards.go +++ b/pkg/registry/apis/dashboard/legacy/sql_dashboards.go @@ -115,7 +115,7 @@ func (a *dashboardSqlAccess) getRows(ctx context.Context, query *DashboardQuery) // } } - sqlcmd := selector + var sqlcmd string args := []any{query.OrgID} limit := query.Limit diff --git a/pkg/services/apiserver/options/storage.go b/pkg/services/apiserver/options/storage.go index 5c2f86ba138..27568c0f96f 100644 --- a/pkg/services/apiserver/options/storage.go +++ b/pkg/services/apiserver/options/storage.go @@ -49,7 +49,7 @@ func (o *StorageOptions) Validate() []error { case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc: // no-op default: - errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc)) + errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc)) } if _, _, err := net.SplitHostPort(o.Address); err != nil { diff --git a/pkg/tests/apis/dashboard/dashboards_test.go b/pkg/tests/apis/dashboard/dashboards_test.go index 8ff9569d91e..7980b6475b2 100644 --- a/pkg/tests/apis/dashboard/dashboards_test.go +++ b/pkg/tests/apis/dashboard/dashboards_test.go @@ -1,6 +1,7 @@ package dashboards import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -47,58 +48,59 @@ func TestIntegrationDashboardsApp(t *testing.T) { t.Run("Check discovery client", func(t *testing.T) { disco := helper.GetGroupVersionInfoJSON("dashboard.grafana.app") - //fmt.Printf("%s", string(disco)) + fmt.Printf("%s", string(disco)) require.JSONEq(t, `[ - { - "freshness": "Current", - "resources": [ - { - "resource": "dashboards", - "responseKind": { - "group": "", - "kind": "Dashboard", - "version": "" - }, - "scope": "Namespaced", - "singularResource": "dashboard", - "subresources": [ - { - "responseKind": { - "group": "", - "kind": "DashboardWithAccessInfo", - "version": "" - }, - "subresource": "dto", - "verbs": [ - "get" - ] - }, - { - "responseKind": { - "group": "", - "kind": "DashboardVersionList", - "version": "" - }, - "subresource": "versions", - "verbs": [ - "get" - ] - } - ], - "verbs": [ - "create", - "delete", - "deletecollection", - "get", - "list", - "patch", - "update" - ] - } - ], - "version": "v0alpha1" - } - ]`, disco) + { + "freshness": "Current", + "resources": [ + { + "resource": "dashboards", + "responseKind": { + "group": "", + "kind": "Dashboard", + "version": "" + }, + "scope": "Namespaced", + "singularResource": "dashboard", + "subresources": [ + { + "responseKind": { + "group": "", + "kind": "DashboardWithAccessInfo", + "version": "" + }, + "subresource": "dto", + "verbs": [ + "get" + ] + }, + { + "responseKind": { + "group": "", + "kind": "PartialObjectMetadataList", + "version": "" + }, + "subresource": "history", + "verbs": [ + "get" + ] + } + ], + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ] + } + ], + "version": "v0alpha1" + } +]`, disco) }) } diff --git a/public/app/features/dashboard-scene/settings/VersionsEditView.tsx b/public/app/features/dashboard-scene/settings/VersionsEditView.tsx index 64dce2537b5..e3f54207bfc 100644 --- a/public/app/features/dashboard-scene/settings/VersionsEditView.tsx +++ b/public/app/features/dashboard-scene/settings/VersionsEditView.tsx @@ -158,7 +158,7 @@ export class VersionsEditView extends SceneObjectBase imp }); }; - public onCheck = (ev: React.FormEvent, versionId: number|string) => { + public onCheck = (ev: React.FormEvent, versionId: number | string) => { this.setState({ versions: this.versions.map((version) => version.version === versionId ? { ...version, checked: ev.currentTarget.checked } : version diff --git a/public/app/features/dashboard-scene/settings/version-history/HistorySrv.ts b/public/app/features/dashboard-scene/settings/version-history/HistorySrv.ts index e4393f6620a..7f64cfe29a0 100644 --- a/public/app/features/dashboard-scene/settings/version-history/HistorySrv.ts +++ b/public/app/features/dashboard-scene/settings/version-history/HistorySrv.ts @@ -7,7 +7,7 @@ export interface HistoryListOpts { start: number; } -// The raw version from +// The raw version from export interface VersionModel { uid: string; version: number | string; // resourceVersion in k8s @@ -33,7 +33,7 @@ class LegacyHistorySrv implements HistorySrv { async getDashboardVersion(dashboardUID: string, version: number): Promise { if (typeof dashboardUID !== 'string') { - return Promise.resolve({}) + return Promise.resolve({}); } const info = await getBackendSrv().get(`api/dashboards/uid/${dashboardUID}/versions/${version}`); @@ -42,7 +42,7 @@ class LegacyHistorySrv implements HistorySrv { restoreDashboard(dashboardUID: string, version: number): Promise { if (typeof dashboardUID !== 'string') { - return Promise.resolve({}) + return Promise.resolve({}); } const url = `api/dashboards/uid/${dashboardUID}/restore`; @@ -51,12 +51,11 @@ class LegacyHistorySrv implements HistorySrv { } } - -let historySrv: HistorySrv|undefined = undefined; +let historySrv: HistorySrv | undefined = undefined; export function getHistorySrv(): HistorySrv { if (!historySrv) { - historySrv = new LegacyHistorySrv() + historySrv = new LegacyHistorySrv(); } - return historySrv + return historySrv; } diff --git a/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx b/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx index fd6ad2799d0..1839899d6fe 100644 --- a/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx @@ -135,8 +135,8 @@ describe('VersionSettings', () => { }); test('clicking show more appends results to the table', async () => { - getHistorySrv().getHistoryList - // @ts-ignore + getHistorySrv() + .getHistoryList// @ts-ignore .mockImplementationOnce(() => Promise.resolve(versions.slice(0, VERSIONS_FETCH_LIMIT))) .mockImplementationOnce( () => new Promise((resolve) => setTimeout(() => resolve(versions.slice(VERSIONS_FETCH_LIMIT)), 1000)) @@ -166,8 +166,8 @@ describe('VersionSettings', () => { test('selecting two versions and clicking compare button should render compare view', async () => { // @ts-ignore historySrv.getHistoryList.mockResolvedValue(versions.slice(0, VERSIONS_FETCH_LIMIT)); - getHistorySrv().getDashboardVersion - // @ts-ignore + getHistorySrv() + .getDashboardVersion// @ts-ignore .mockImplementationOnce(() => Promise.resolve(diffs.lhs)) .mockImplementationOnce(() => Promise.resolve(diffs.rhs));