minor lint fixes

This commit is contained in:
Ryan McKinley 2024-07-01 08:12:28 -07:00
parent 9f2aae1c48
commit fe8a05c648
6 changed files with 66 additions and 65 deletions

View File

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

View File

@ -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 {

View File

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

View File

@ -158,7 +158,7 @@ export class VersionsEditView extends SceneObjectBase<VersionsEditViewState> imp
});
};
public onCheck = (ev: React.FormEvent<HTMLInputElement>, versionId: number|string) => {
public onCheck = (ev: React.FormEvent<HTMLInputElement>, versionId: number | string) => {
this.setState({
versions: this.versions.map((version) =>
version.version === versionId ? { ...version, checked: ev.currentTarget.checked } : version

View File

@ -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<Dashboard | {}> {
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<SaveDashboardResponseDTO | {}> {
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;
}

View File

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