Toolkit: catch errors from signing service (#23486)

This commit is contained in:
Ryan McKinley 2020-04-09 13:30:34 -07:00 committed by GitHub
parent 2da704be55
commit b710f21a06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,18 +77,23 @@ const manifestRunner: TaskRunner<ManifestOptions> = async ({ folder }) => {
console.log('Request Signature:', url);
const axios = require('axios');
const info = await axios.post(url, manifest, {
headers: { Authorization: 'Bearer ' + GRAFANA_API_KEY },
responseType: 'arraybuffer',
});
if (info.status === 200) {
console.log('OK: ', info.data);
const buffer = new Buffer(info.data, 'binary');
fs.writeFileSync(outputPath, buffer);
} else {
console.warn('Error: ', info);
console.log('Saving the unsigned manifest');
fs.writeFileSync(outputPath, JSON.stringify(manifest, null, 2));
try {
const info = await axios.post(url, manifest, {
headers: { Authorization: 'Bearer ' + GRAFANA_API_KEY },
responseType: 'arraybuffer',
});
if (info.status === 200) {
console.log('OK: ', info.data);
const buffer = new Buffer(info.data, 'binary');
fs.writeFileSync(outputPath, buffer);
} else {
console.warn('Error: ', info);
console.log('Saving the unsigned manifest');
fs.writeFileSync(outputPath, JSON.stringify(manifest, null, 2));
}
} catch (err) {
console.log('ERROR Fetching response', err);
}
};