Auto-merge for PR #676 via VersionBot

Ensure hostname truly is optional when configuring device images
This commit is contained in:
resin-io-versionbot[bot] 2017-10-09 10:14:35 +00:00 committed by GitHub
commit b4a56e1541
4 changed files with 41 additions and 10 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).
## v6.6.10 - 2017-10-09
* Ensure hostname truly is optional when configuring device images #676 [Tim Perry]
## v6.6.9 - 2017-10-06
* Fix resin preload --splash-image argument handling #678 [Alexis Svinartchouk]

View File

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var BOOT_PARTITION, CONNECTIONS_FOLDER, CONNECTION_FILE, getConfiguration, getConfigurationSchema, inquirerOptions, prepareConnectionFile;
var BOOT_PARTITION, CONNECTIONS_FOLDER, CONNECTION_FILE, getConfiguration, getConfigurationSchema, inquirerOptions, prepareConnectionFile, removeHostname;
BOOT_PARTITION = {
primary: 1
@ -31,10 +31,14 @@ getConfigurationSchema = function(connnectionFileName) {
mapper: [
{
template: {
hostname: '{{hostname}}',
persistentLogging: '{{persistentLogging}}'
},
domain: [['config_json', 'hostname'], ['config_json', 'persistentLogging']]
domain: [['config_json', 'persistentLogging']]
}, {
template: {
hostname: '{{hostname}}'
},
domain: [['config_json', 'hostname']]
}, {
template: {
wifi: {
@ -157,8 +161,16 @@ prepareConnectionFile = function(target) {
partition: BOOT_PARTITION,
path: CONNECTIONS_FOLDER + "/resin-wifi"
}, CONNECTION_FILE).thenReturn(null);
}).then(function(connnectionFileName) {
return getConfigurationSchema(connnectionFileName);
}).then(function(connectionFileName) {
return getConfigurationSchema(connectionFileName);
});
};
removeHostname = function(schema) {
var _;
_ = require('lodash');
return schema.mapper = _.reject(schema.mapper, function(mapper) {
return _.isEqual(Object.keys(mapper.template), ['hostname']);
});
};
@ -185,6 +197,9 @@ module.exports = {
}).then(function(configurationSchema) {
return denymount(params.target, function(cb) {
return reconfix.readConfiguration(configurationSchema, params.target).then(getConfiguration).then(function(answers) {
if (!answers.hostname) {
removeHostname(configurationSchema);
}
return reconfix.writeConfiguration(configurationSchema, answers, params.target);
}).asCallback(cb);
});

View File

@ -21,13 +21,18 @@ getConfigurationSchema = (connnectionFileName = 'resin-wifi') ->
mapper: [
{
template:
hostname: '{{hostname}}'
persistentLogging: '{{persistentLogging}}'
domain: [
[ 'config_json', 'hostname' ]
[ 'config_json', 'persistentLogging' ]
]
}
{
template:
hostname: '{{hostname}}'
domain: [
[ 'config_json', 'hostname' ]
]
}
{
template:
wifi:
@ -176,8 +181,13 @@ prepareConnectionFile = (target) ->
, CONNECTION_FILE
.thenReturn(null)
.then (connnectionFileName) ->
return getConfigurationSchema(connnectionFileName)
.then (connectionFileName) ->
return getConfigurationSchema(connectionFileName)
removeHostname = (schema) ->
_ = require('lodash')
schema.mapper = _.reject schema.mapper, (mapper) ->
_.isEqual(Object.keys(mapper.template), ['hostname'])
module.exports =
signature: 'local configure <target>'
@ -209,6 +219,8 @@ module.exports =
reconfix.readConfiguration(configurationSchema, params.target)
.then(getConfiguration)
.then (answers) ->
if not answers.hostname
removeHostname(configurationSchema)
reconfix.writeConfiguration(configurationSchema, answers, params.target)
.asCallback(cb)
.then ->

View File

@ -1,6 +1,6 @@
{
"name": "resin-cli",
"version": "6.6.9",
"version": "6.6.10",
"description": "The official resin.io CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",