diff --git a/.betterer.results b/.betterer.results index aa85a9c3e05..278d3a84a8a 100644 --- a/.betterer.results +++ b/.betterer.results @@ -896,20 +896,6 @@ exports[`better eslint`] = { "packages/grafana-toolkit/src/cli/tasks/plugin/bundle.managed.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-toolkit/src/cli/tasks/searchTestDataSetup.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"], - [0, 0, 0, "Unexpected any. Specify a different type.", "8"], - [0, 0, 0, "Unexpected any. Specify a different type.", "9"], - [0, 0, 0, "Unexpected any. Specify a different type.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"] - ], "packages/grafana-toolkit/src/cli/tasks/task.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], diff --git a/packages/grafana-toolkit/src/cli/index.ts b/packages/grafana-toolkit/src/cli/index.ts index 593fb9bb3fd..037288731f0 100644 --- a/packages/grafana-toolkit/src/cli/index.ts +++ b/packages/grafana-toolkit/src/cli/index.ts @@ -9,7 +9,6 @@ import { pluginSignTask } from './tasks/plugin.sign'; import { pluginUpdateTask } from './tasks/plugin.update'; import { getToolkitVersion, githubPublishTask } from './tasks/plugin.utils'; import { bundleManagedTask } from './tasks/plugin/bundle.managed'; -import { searchTestDataSetupTask } from './tasks/searchTestDataSetup'; import { templateTask } from './tasks/template'; import { toolkitBuildTask } from './tasks/toolkit.build'; import { execTask } from './utils/execTask'; @@ -65,19 +64,6 @@ export const run = (includeInternalScripts = false) => { ); await execTask(toolkitBuildTask)({}); }); - - program - .command('searchTestData') - .option('-c, --count ', 'Specify number of dashboards') - .description('[deprecated] Setup test data for search') - .action(async (cmd) => { - console.log( - chalk.yellow.bold( - `⚠️ This command is deprecated and will be removed in v10. No further support will be provided. ⚠️` - ) - ); - await execTask(searchTestDataSetupTask)({ count: cmd.count }); - }); } program.option('-v, --version', 'Toolkit version').action(async () => { diff --git a/packages/grafana-toolkit/src/cli/tasks/searchTestDataSetup.ts b/packages/grafana-toolkit/src/cli/tasks/searchTestDataSetup.ts deleted file mode 100644 index 6f8fc346e6d..00000000000 --- a/packages/grafana-toolkit/src/cli/tasks/searchTestDataSetup.ts +++ /dev/null @@ -1,117 +0,0 @@ -import axios from 'axios'; - -import { Task, TaskRunner } from './task'; - -interface SearchTestDataSetupOptions { - count: number; -} - -const client = axios.create({ - baseURL: 'http://localhost:3000/api', - auth: { - username: 'admin', - password: 'admin2', - }, -}); - -export async function getUser(user: any): Promise { - console.log('Creating user ' + user.name); - const search = await client.get('/users/search', { - params: { query: user.login }, - }); - - if (search.data.totalCount === 1) { - user.id = search.data.users[0].id; - return user; - } - - const rsp = await client.post('/admin/users', user); - user.id = rsp.data.id; - return user; -} - -export async function getTeam(team: any): Promise { - // delete if exists - const teams = await client.get('/teams/search'); - for (const existing of teams.data.teams) { - if (existing.name === team.name) { - console.log('Team exists, deleting'); - await client.delete('/teams/' + existing.id); - } - } - - console.log('Creating team ' + team.name); - const teamRsp = await client.post(`/teams`, team); - team.id = teamRsp.data.teamId; - return team; -} - -export async function addToTeam(team: any, user: any): Promise { - console.log(`Adding user ${user.name} to team ${team.name}`); - await client.post(`/teams/${team.id}/members`, { userId: user.id }); -} - -export async function setDashboardAcl(dashboardId: any, aclList: any) { - console.log('Setting Dashboard ACL ' + dashboardId); - await client.post(`/dashboards/id/${dashboardId}/permissions`, { items: aclList }); -} - -const searchTestDataSetupRunner: TaskRunner = async ({ count }) => { - const user1 = await getUser({ - name: 'searchTestUser1', - email: 'searchTestUser@team.com', - login: 'searchTestUser1', - password: '12345', - }); - - const team1 = await getTeam({ name: 'searchTestTeam1', email: 'searchtestdata@team.com' }); - addToTeam(team1, user1); - - // create or update folder - const folder: any = { - uid: 'search-test-data', - title: 'Search test data folder', - version: 1, - }; - - try { - await client.delete(`/folders/${folder.uid}`); - } catch (err) {} - - console.log('Creating folder'); - - const rsp = await client.post(`/folders`, folder); - folder.id = rsp.data.id; - folder.url = rsp.data.url; - - await setDashboardAcl(folder.id, []); - - console.log('Creating dashboards'); - - const dashboards: any = []; - - for (let i = 0; i < count; i++) { - const dashboard: any = { - uid: 'search-test-dash-' + i.toString().padStart(5, '0'), - title: 'Search test dash ' + i.toString().padStart(5, '0'), - }; - - const rsp = await client.post(`/dashboards/db`, { - dashboard: dashboard, - folderId: folder.id, - overwrite: true, - }); - - dashboard.id = rsp.data.id; - dashboard.url = rsp.data.url; - - console.log('Created dashboard ' + dashboard.title); - dashboards.push(dashboard); - await setDashboardAcl(dashboard.id, [{ userId: 0, teamId: team1.id, permission: 4 }]); - } -}; - -export const searchTestDataSetupTask = new Task( - 'Search test data setup', - searchTestDataSetupRunner -);