unmanged: Don't require a device name when setting a target state

Also set a default device name of 'local', to avoid an undefined value.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2018-11-29 11:23:05 +00:00
parent eda477ff86
commit 64a8c03eba
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
3 changed files with 5 additions and 5 deletions

View File

@ -64,7 +64,7 @@ class Config extends EventEmitter {
// NOTE: all 'db' values are stored and loaded as *strings*, // NOTE: all 'db' values are stored and loaded as *strings*,
apiSecret: { source: 'db', mutable: true }, apiSecret: { source: 'db', mutable: true },
name: { source: 'db', mutable: true }, name: { source: 'db', mutable: true, default: 'local' },
initialConfigReported: { source: 'db', mutable: true, default: 'false' }, initialConfigReported: { source: 'db', mutable: true, default: 'false' },
initialConfigSaved: { source: 'db', mutable: true, default: 'false' }, initialConfigSaved: { source: 'db', mutable: true, default: 'false' },
containersNormalised: { source: 'db', mutable: true, default: 'false' }, containersNormalised: { source: 'db', mutable: true, default: 'false' },

View File

@ -19,8 +19,8 @@ DeviceConfig = require './device-config'
ApplicationManager = require './application-manager' ApplicationManager = require './application-manager'
validateLocalState = (state) -> validateLocalState = (state) ->
if !state.name? or !validation.isValidShortText(state.name) if state.name?
throw new Error('Invalid device name') throw new Error('Invalid device name') if not validation.isValidShortText(state.name)
if !state.apps? or !validation.isValidAppsObject(state.apps) if !state.apps? or !validation.isValidAppsObject(state.apps)
throw new Error('Invalid apps') throw new Error('Invalid apps')
if !state.config? or !validation.isValidEnv(state.config) if !state.config? or !validation.isValidEnv(state.config)

View File

@ -58,8 +58,8 @@ describe 'Config', ->
expect(promise).to.eventually.deep.equal({ appUpdatePollInterval: 30000, name: 'a new device name' }) expect(promise).to.eventually.deep.equal({ appUpdatePollInterval: 30000, name: 'a new device name' })
it 'allows removing a db key', -> it 'allows removing a db key', ->
promise = @conf.remove('name').then => promise = @conf.remove('apiSecret').then =>
@conf.get('name') @conf.get('apiSecret')
expect(promise).to.be.fulfilled expect(promise).to.be.fulfilled
expect(promise).to.eventually.be.undefined expect(promise).to.eventually.be.undefined