Grafana Toolkit: add an option for signing plugins as admin (#26817)

* feat(grafana-toolkit): add a flag to the plugin:ci-package command

* docs(grafana-toolkit): add a short comment above the flag

* fix(grafana-toolkit): fix option for signing a plugin with the admin endpoint
This commit is contained in:
Levente Balogh
2020-08-07 15:34:30 +02:00
committed by GitHub
parent 9c81c7aa44
commit 6b1a80675f
2 changed files with 11 additions and 4 deletions
+4 -1
View File
@@ -194,9 +194,12 @@ export const run = (includeInternalScripts = false) => {
program
.command('plugin:ci-package')
.option('--signing-admin', 'Use the admin API endpoint for signing the manifest.', false)
.description('Create a zip packages for the plugin')
.action(async cmd => {
await execTask(ciPackagePluginTask)({});
await execTask(ciPackagePluginTask)({
signingAdmin: cmd.signingAdmin,
});
});
program
@@ -26,6 +26,7 @@ const rimraf = promisify(rimrafCallback);
export interface PluginCIOptions {
finish?: boolean;
upload?: boolean;
signingAdmin?: boolean;
}
/**
@@ -106,7 +107,7 @@ export const ciBuildPluginDocsTask = new Task<PluginCIOptions>('Build Plugin Doc
* 2. zip it into packages in `~/ci/packages`
* 3. prepare grafana environment in: `~/ci/grafana-test-env`
*/
const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
const packagePluginRunner: TaskRunner<PluginCIOptions> = async ({ signingAdmin }) => {
const start = Date.now();
const ciDir = getCiFolder();
const packagesDir = path.resolve(ciDir, 'packages');
@@ -161,9 +162,12 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
}
});
// Write a manifest.txt file in the dist folder
// Write a MANIFEST.txt file in the dist folder
// By using the --signing-admin flag the plugin doesn't need to be in the plugins database to be signed,
// however it requires an Admin API key.
try {
await execa('grabpl', ['build-plugin-manifest', distContentDir]);
const grabplCommandFlags = signingAdmin ? ['build-plugin-manifest', '--signing-admin'] : ['build-plugin-manifest'];
await execa('grabpl', [...grabplCommandFlags, distContentDir]);
} catch (err) {
console.warn(`Error signing manifest: ${distContentDir}`, err);
}