mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-21 00:23:22 +00:00
fix: Store and retrieve device config without namespaces
This avoids issues on provisioning where the current state (esp. config.txt) that we want to save is retrieved without a RESIN_ or BALENA_ prefix, causing those values to be lost. Change-type: patch Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
This commit is contained in:
20
src/migrations/M00000.js
Normal file
20
src/migrations/M00000.js
Normal file
@ -0,0 +1,20 @@
|
||||
const _ = require('lodash');
|
||||
|
||||
// We take legacy deviceConfig targets and store them without the RESIN_ prefix
|
||||
// (we also strip the BALENA_ prefix for completeness, even though no supervisors
|
||||
// using this prefix made it to production)
|
||||
exports.up = function (knex, Promise) {
|
||||
return knex('deviceConfig').select('targetValues')
|
||||
.then((devConfigs) => {
|
||||
const devConfig = devConfigs[0];
|
||||
const targetValues = JSON.parse(devConfig.targetValues);
|
||||
const filteredTargetValues = _.mapKeys( (_v, k) => {
|
||||
return k.replace(/^(?:RESIN|BALENA)_(.*)/, '$1');
|
||||
});
|
||||
return knex('deviceConfig').update({ targetValues: JSON.stringify(filteredTargetValues) });
|
||||
});
|
||||
}
|
||||
|
||||
exports.down = function (knex, Promise) {
|
||||
return Promise.reject(new Error('Not Implemented'));
|
||||
}
|
Reference in New Issue
Block a user