mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 09:16:38 +00:00
feat(GUI): blacklist drives with an env var (#2315)
We add an environment variable `ETCHER_BLACKLISTED_DRIVES` that allows us to filter certain drives from ever showing up in Etcher with comma separated device paths, e.g. `/dev/sda,/dev/sdb,/dev/mmcblk0`. Closes: https://github.com/resin-io/etcher/issues/2264 Change-Type: patch Changelog-Entry: Allow blacklisting of drives through and environment variable ETCHER_BLACKLISTED_DRIVES.
This commit is contained in:
parent
2cdb6945ba
commit
66c7806cfa
@ -47,6 +47,8 @@ const driveScanner = require('./modules/drive-scanner')
|
|||||||
const osDialog = require('./os/dialog')
|
const osDialog = require('./os/dialog')
|
||||||
const exceptionReporter = require('./modules/exception-reporter')
|
const exceptionReporter = require('./modules/exception-reporter')
|
||||||
|
|
||||||
|
/* eslint-disable lodash/prefer-lodash-method */
|
||||||
|
|
||||||
// Enable debug information from all modules that use `debug`
|
// Enable debug information from all modules that use `debug`
|
||||||
// See https://github.com/visionmedia/debug#browser-support
|
// See https://github.com/visionmedia/debug#browser-support
|
||||||
//
|
//
|
||||||
@ -55,6 +57,16 @@ const exceptionReporter = require('./modules/exception-reporter')
|
|||||||
process.env.DRIVELIST_DEBUG = /drivelist|^\*$/i.test(process.env.DEBUG) ? '1' : ''
|
process.env.DRIVELIST_DEBUG = /drivelist|^\*$/i.test(process.env.DEBUG) ? '1' : ''
|
||||||
window.localStorage.debug = process.env.DEBUG
|
window.localStorage.debug = process.env.DEBUG
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Environment variable blacklisted drives by path
|
||||||
|
* @type {Array<String>}
|
||||||
|
* @constant
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
const BLACKLISTED_DRIVES = process.env.ETCHER_BLACKLISTED_DRIVES
|
||||||
|
? process.env.ETCHER_BLACKLISTED_DRIVES.split(',')
|
||||||
|
: []
|
||||||
|
|
||||||
const app = angular.module('Etcher', [
|
const app = angular.module('Etcher', [
|
||||||
require('angular-ui-router'),
|
require('angular-ui-router'),
|
||||||
require('angular-ui-bootstrap'),
|
require('angular-ui-bootstrap'),
|
||||||
@ -209,7 +221,14 @@ app.run(($timeout) => {
|
|||||||
// available drives list has changed, and incorrectly
|
// available drives list has changed, and incorrectly
|
||||||
// keeps asking the user to "Connect a drive".
|
// keeps asking the user to "Connect a drive".
|
||||||
$timeout(() => {
|
$timeout(() => {
|
||||||
availableDrives.setDrives(drives)
|
if (BLACKLISTED_DRIVES.length) {
|
||||||
|
const allowedDrives = drives.filter((drive) => {
|
||||||
|
return !BLACKLISTED_DRIVES.includes(drive.device)
|
||||||
|
})
|
||||||
|
availableDrives.setDrives(allowedDrives)
|
||||||
|
} else {
|
||||||
|
availableDrives.setDrives(drives)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user